コード例 #1
0
ファイル: BaseManager.php プロジェクト: Redpill-Linpro/gamine
 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;
 }
コード例 #2
0
ファイル: BaseModel.php プロジェクト: Redpill-Linpro/gamine
 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;
     }
 }