public function findOneById($id, $params = array()) { $resource = $this->getEntityResource(); $data = $this->access_service->findOneById($resource, $id, $params); if (!$data) { return null; } $object = $this->gamine_service->instantiateModel($this->entity_key); $object->fromDataArray($data); return $object; }
protected function _mapRelationData($property, $data, $mappings) { if ($mappings['collection']) { $models = array(); foreach ($data as $single_result) { $related_model = $this->_gamineservice->instantiateModel($mappings['entity']); $related_model->fromDataArray($single_result); $related_model->setResourceLocationPrefix($this->_getResourceLocation() . "/"); if ($related_model->hasDataArrayIdentifierValue()) { $models[(string) $related_model->getDataArrayIdentifierValue()] = $related_model; } else { $models[] = $object; } } $this->{$property} = $models; } else { $related_model = $this->_gamineservice->instantiateModel($mappings['entity']); $related_model->fromDataArray($data); $related_model->setResourceLocationPrefix($this->_getResourceLocation() . "/"); $this->{$property} = $related_model; } }