private function TripalContentService_v0_1::sanitizeFieldEntity
3.x TripalContentService_v0_1.inc | private TripalContentService_v0_1::sanitizeFieldEntity(&$items, $service_path) |
Rewrites any TripalEntity elements in the values array for use with WS.
1 call to TripalContentService_v0_1::sanitizeFieldEntity()
- TripalContentService_v0_1::sanitizeFieldKeys in tripal_ws/
includes/ TripalWebService/ TripalContentService_v0_1.inc - Rewrites the keys of a field's items array for use with web services.
File
- tripal_ws/
includes/ TripalWebService/ TripalContentService_v0_1.inc, line 482
Class
Code
private function sanitizeFieldEntity(&$items, $service_path) {
if (!$items) {
return;
}
foreach ($items as $key => $value) {
if (is_array($value)) {
$this->sanitizeFieldEntity($items[$key], $service_path);
continue;
}
if ($key == 'entity') {
list($item_etype, $item_eid) = explode(':', $items['entity']);
if ($item_eid) {
$item_entity = tripal_load_entity($item_etype, array($item_eid));
$item_entity = reset($item_entity);
$bundle = tripal_load_bundle_entity(array('name' => $item_entity->bundle));
$items['@id'] = $this->getServicePath() . '/' . urlencode($bundle->label) . '/' . $item_eid;
}
unset($items['entity']);
}
}
}