Domanda

I am using zf-boilerplate for my zend framework project. I am using the Gedmo extensions and need to get an instance of the doctrine event manager in the bootstrap.

ie. I would like to be able to do the following:

$evm = $this->getDoctrine()->getEventManager()

How can I do this?

È stato utile?

Soluzione

You can access the entity manager by calling

Zend_Registry::get('em');

If you're in the middle of bootsrap, then make sure you bootstrap entity manager before accessing it.

Just like resource methods, you use the bootstrap() method to execute resource plugins. Just like with resource methods, you can specify either a single resource plugin, multiple plugins (via an array), or all plugins. Additionally, you can mix and match to execute resource methods as well. (Zend Framework manual)

i.e. execute the code below first

// Execute all resource methods and plugins:
$bootstrap->bootstrap('doctrine');

UPDATE

Didn't notice the question was about EventManager. Use the code below in order to get access to it

Zend_Registry::get('doctrine')->getEventManager ();

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top