/** * @param $obj * @return array */ public function toArray($obj) { return $this->mapper->toArray($obj); }
/** * 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; } }