Created
November 19, 2012 19:36
-
-
Save rufinus/4113169 to your computer and use it in GitHub Desktop.
Seems not to be called
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Admin\Hydrator; | |
use cwdCommon\Doctrine\EntityManagerAwareInterface; | |
use Zend\Stdlib\Hydrator\Strategy\DefaultStrategy; | |
class AgencyStrategy extends DefaultStrategy implements EntityManagerAwareInterface | |
{ | |
/** | |
* @var \Doctrine\ORM\EntityManager | |
*/ | |
private $em; | |
public function extract($value) | |
{ | |
echo 'extract - i got called'; | |
$result = array(); | |
foreach ($value as $instance) { | |
$result[] = $instance->getAgencyId(); | |
} | |
return $result; | |
} | |
public function hydrate($value) | |
{ | |
echo 'hydrate - i got called'; | |
$result = $value; | |
if (is_array($value)) { | |
$result = array(); | |
foreach ($value as $id) { | |
$result[] = $this->findEntity($id); | |
} | |
} | |
return $result; | |
} | |
private function findEntity($id) | |
{ | |
return $this->getEntityManager()->find('Admin\Entity\Agency', $id); | |
} | |
public function getEntityManager() | |
{ | |
return $this->em; | |
} | |
/* (non-PHPdoc) | |
* @see \cwdCommon\Doctrine\EntityManagerAwareInterface::setEntityManager() | |
*/ | |
public function setEntityManager(\Doctrine\ORM\EntityManager $em) { | |
$this->em = $em; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment