コード例 #1
0
 /**
  * @param $obj
  * @return array
  */
 public function toArray($obj)
 {
     return $this->mapper->toArray($obj);
 }
コード例 #2
0
ファイル: Outlet.php プロジェクト: jimmydivvy/outlet-orm
 /**
  * Return the entity for a database row
  * This method checks the identity map
  *
  * @param string $clazz
  * @param array $row
  */
 public function getEntityForRow($clazz, array $row)
 {
     OutletMapper::castRow($clazz, $row);
     // get the pk column in order to check the map
     $pks = $this->getConfig()->getEntity($clazz)->getPkFields();
     $values = array();
     foreach ($pks as $pk) {
         $values[] = $row[$pk];
     }
     $data = OutletMapper::get($clazz, $values);
     $proxyclass = "{$clazz}_OutletProxy";
     if ($data) {
         return $data['obj'];
     } else {
         $obj = self::populateObject($clazz, new $proxyclass(), $row);
         // add it to the cache
         OutletMapper::set($clazz, $values, array('obj' => $obj, 'original' => OutletMapper::toArray($obj)));
         return $obj;
     }
 }