opensolutions/doctrine2bridge

How to use (pass) EntityMenager to another function.

Closed this issue · 2 comments

Sometimes there is a need to use the EntityManager as a parameter to some function.
Using facades in Laravel is posible:
KLASS :: FUNCTION ().
example:
$metadata = D2EM::getClassMetadata('Entities\Deliveries');

You can not use CLASS without (:: FUNCTION()).
example:
$em = D2EM;
Error: Use of undefined constant D2EM - Assumed 'D2EM'

How to pass the EntityManager to function as a parameter.
example:
$ evm = new \ Doctrine\Common\EventManager ();
$ translatableListener = new \Gedmo\Translatable\TranslatableListener;
$ transl = $ translatableListener-> getConfiguration (D2EM, 'Entities\Deliveries');

D2EM is a standard Laravel 4 facade. As such, you can get the underlying EntityManager instance via:

D2EM::getFacadeRoot()

Thank you very much.