Created
January 4, 2012 16:58
-
-
Save fritz-gerneth/1560962 to your computer and use it in GitHub Desktop.
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
class InjectLocatorListener implements \Doctrine\Common\EventSubscriber, \Zend\Loader\LocatorAware | |
{ | |
protected $locator; | |
public function postLoad(\Doctrine\ORM\Event\LifecycleEventArgs $eventArgs) | |
{ | |
$entity = $eventArgs->getEntity(); | |
if($entity instanceof \Zend\Loader\LocatorAware) | |
{ | |
$entity->setLocator($this->getLocator()); | |
} | |
} | |
public function getSubscribedEvents() | |
{ | |
return array(\Doctrine\ORM\Events::postLoad); | |
} | |
public function getLocator() | |
{ | |
return $this->locator; | |
} | |
public function setLocator(\Zend\Di\Locator $locator) | |
{ | |
$this->locator = $locator; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment