Skip to content

Instantly share code, notes, and snippets.

@fritz-gerneth
Created January 4, 2012 16:58
Show Gist options
  • Save fritz-gerneth/1560962 to your computer and use it in GitHub Desktop.
Save fritz-gerneth/1560962 to your computer and use it in GitHub Desktop.
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