From 500cf836598d782bbd212cbfac22ab9dffbefa0a Mon Sep 17 00:00:00 2001 From: "Yuriy V. Yukhimenko" Date: Fri, 27 Jun 2014 00:26:18 +0300 Subject: [PATCH 1/4] Fix: Inject the service locator instance into all SL-aware fixtures on add. --- .../Command/ImportCommand.php | 42 ++++++++++++------- src/DoctrineDataFixtureModule/Module.php | 5 ++- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/DoctrineDataFixtureModule/Command/ImportCommand.php b/src/DoctrineDataFixtureModule/Command/ImportCommand.php index f153d41..c14ad84 100644 --- a/src/DoctrineDataFixtureModule/Command/ImportCommand.php +++ b/src/DoctrineDataFixtureModule/Command/ImportCommand.php @@ -26,9 +26,10 @@ use Symfony\Component\Console\Input\InputOption; use Doctrine\ORM\Tools\SchemaTool; use Doctrine\DBAL\Migrations\Configuration\Configuration; +use DoctrineDataFixtureModule\Loader\ServiceLocatorAwareLoader as Loader; use Doctrine\Common\DataFixtures\Executor\ORMExecutor; use Doctrine\Common\DataFixtures\Purger\ORMPurger; -use DoctrineDataFixtureModule\Loader\ServiceLocatorAwareLoader; +use Zend\ServiceManager\ServiceLocatorAwareInterface; use Zend\ServiceManager\ServiceLocatorInterface; /** @@ -40,25 +41,15 @@ * @since 2.0 * @author Jonathan Wage */ -class ImportCommand extends Command +class ImportCommand extends Command implements ServiceLocatorAwareInterface { protected $paths; protected $em; - - /** - * Service Locator instance - * @var Zend\ServiceManager\ServiceLocatorInterface - */ - protected $serviceLocator; + + protected $sl; const PURGE_MODE_TRUNCATE = 2; - - public function __construct(ServiceLocatorInterface $serviceLocator) - { - $this->serviceLocator = $serviceLocator; - parent::__construct(); - } protected function configure() { @@ -77,7 +68,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $loader = new ServiceLocatorAwareLoader($this->serviceLocator); + $loader = new Loader($this->sm); $purger = new ORMPurger(); if ($input->getOption('purge-with-truncate')) { @@ -101,4 +92,25 @@ public function setEntityManager($em) { $this->em = $em; } + + /** + * Set service locator + * + * @param ServiceLocatorInterface $serviceLocator + */ + public function setServiceLocator(ServiceLocatorInterface $serviceLocator) + { + $this->sl = $serviceLocator; + } + + /** + * Get service locator + * + * @return ServiceLocatorInterface + */ + public function getServiceLocator() + { + return $this->sl; + } + } diff --git a/src/DoctrineDataFixtureModule/Module.php b/src/DoctrineDataFixtureModule/Module.php index a229110..bdb1e3a 100644 --- a/src/DoctrineDataFixtureModule/Module.php +++ b/src/DoctrineDataFixtureModule/Module.php @@ -66,13 +66,14 @@ public function init(ModuleManager $e) /* @var $cli \Symfony\Component\Console\Application */ $cli = $e->getTarget(); - /* @var $sm ServiceLocatorInterface */ + /* @var $sm \Zend\ServiceManager\ServiceLocatorInterface */ $sm = $e->getParam('ServiceManager'); $em = $sm->get('doctrine.entitymanager.orm_default'); $paths = $sm->get('doctrine.configuration.fixtures'); - $importCommand = new ImportCommand($sm); + $importCommand = new ImportCommand(); $importCommand->setEntityManager($em); + $importCommand->setServiceLocator($sm); $importCommand->setPath($paths); ConsoleRunner::addCommands($cli); $cli->addCommands(array( From cc6ca92944ff2f1acabbaf7d6eedce38eea80ea8 Mon Sep 17 00:00:00 2001 From: Yuriy Yukhimenko Date: Fri, 27 Jun 2014 00:56:50 +0300 Subject: [PATCH 2/4] Update ImportCommand.php --- src/DoctrineDataFixtureModule/Command/ImportCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/DoctrineDataFixtureModule/Command/ImportCommand.php b/src/DoctrineDataFixtureModule/Command/ImportCommand.php index c14ad84..3e2dae8 100644 --- a/src/DoctrineDataFixtureModule/Command/ImportCommand.php +++ b/src/DoctrineDataFixtureModule/Command/ImportCommand.php @@ -112,5 +112,4 @@ public function getServiceLocator() { return $this->sl; } - } From bac4f6a2297f6e2cb18c6d7b9e0f5c1987014ecf Mon Sep 17 00:00:00 2001 From: Yuriy Yukhimenko Date: Fri, 27 Jun 2014 13:18:56 +0300 Subject: [PATCH 3/4] Update composer.json --- composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 2896488..cd55027 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "name": "hounddog/doctrine-data-fixture-module", - "description": "Zend Framework 2 Module that provides Doctrine Data-Fixture functionality", + "name": "ontario/doctrine-data-fixture-module", + "description": "Zend Framework 2 Module that provides Doctrine Data-Fixture with Fixteres SL injection functionality", "type": "library", "license": "MIT", "keywords": [ @@ -9,11 +9,11 @@ "module", "zf2" ], - "homepage": "http://www.doctrine-project.org/", + "homepage": "http://www.ontario.pp.ua/", "authors": [ { - "name": "Martin Shwalbe", - "email": "martin.shwalbe@gmail.com" + "name": "Yuriy V. Yukhimenko", + "email": "netmorpheusua@gmail.com" } ], "require": { From 1919b685828b78e74ba4baae7710dda06b8545b7 Mon Sep 17 00:00:00 2001 From: Yuriy Yukhimenko Date: Fri, 27 Jun 2014 13:26:55 +0300 Subject: [PATCH 4/4] Update ImportCommand.php --- src/DoctrineDataFixtureModule/Command/ImportCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DoctrineDataFixtureModule/Command/ImportCommand.php b/src/DoctrineDataFixtureModule/Command/ImportCommand.php index 3e2dae8..9b42596 100644 --- a/src/DoctrineDataFixtureModule/Command/ImportCommand.php +++ b/src/DoctrineDataFixtureModule/Command/ImportCommand.php @@ -68,7 +68,7 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $loader = new Loader($this->sm); + $loader = new Loader($this->sl); $purger = new ORMPurger(); if ($input->getOption('purge-with-truncate')) {