DoctrineDataFixtureModule icon indicating copy to clipboard operation
DoctrineDataFixtureModule copied to clipboard

Usage with alternate EntityManager (via: SwissEngine/Doctrine-Module-Extension)

Open stephaun opened this issue 10 years ago • 1 comments

This module ignores the --em=orm_alterante flag provided by SwissEngine/Doctrine-Module-Extension.

After a little debugging this is because the EntityManager is set in the "loadCli.post" event, before the CLI Helper even is made aware of the alternate EntityManager.

I have come up with a quick hack of a solution: Load the EntityManager from the CLI Helper inside the execute() { } function

ie, change:

public function execute(InputInterface $input, OutputInterface $output)
{
        $loader = new ServiceLocatorAwareLoader($this->serviceLocator);
        $purger = new ORMPurger();
        // etc...

to:

public function execute(InputInterface $input, OutputInterface $output)
{
        $em = $this->getHelper('em')->getEntityManager();
        $this->setEntityManager($em);
        $loader = new ServiceLocatorAwareLoader($this->serviceLocator);
        $purger = new ORMPurger();
        // etc  ....

stephaun avatar Jun 16 '15 23:06 stephaun

Sorry everyone, I am still relatively new and don't really know how to make an official pull/push/fork request....

stephaun avatar Jun 16 '15 23:06 stephaun