From bad41888362ffc4c2124d6a4d79d0aa0c003164d Mon Sep 17 00:00:00 2001 From: Diego Pereira Grassato Date: Sat, 24 Dec 2016 16:05:54 -0200 Subject: [PATCH] Fix group in command line integration with doctrina loadCli --- README.md | 6 +++--- .../Command/DoctrineMongoODMDatafixtureCommand.php | 5 ++++- src/DoctrineMongoODMDatafixture/Module.php | 10 +++++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f065a1b..d229d5e 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Installation To install is quite simple, add the **composer.json:** ``` - "diegograssato/doctrine-odm-datafixture": "dev-master" + "diegograssato/doctrine-odm-datafixture": "1.*" ``` Next step is to update the composer @@ -27,9 +27,9 @@ Then add **DoctrineMongoODMDatafixture** to your **config/application.config.php In **module.config.php** you should inform the folder where your fixtures, for example: ``` - 'odm-data-fixtures' => array( + 'odm-data-fixtures' => [ __NAMESPACE__.'_fixtures' => __DIR__.'/../src/Fixtures', - ), + ] ``` diff --git a/src/DoctrineMongoODMDatafixture/Command/DoctrineMongoODMDatafixtureCommand.php b/src/DoctrineMongoODMDatafixture/Command/DoctrineMongoODMDatafixtureCommand.php index ae2a17a..a2ea201 100644 --- a/src/DoctrineMongoODMDatafixture/Command/DoctrineMongoODMDatafixtureCommand.php +++ b/src/DoctrineMongoODMDatafixture/Command/DoctrineMongoODMDatafixtureCommand.php @@ -140,6 +140,7 @@ protected function findFixtureInApplication() protected function isGroupSupport() { + if(count($this->fixturesConfig) === 0) { return false; } @@ -169,7 +170,9 @@ protected function getPathFromConig(InputInterface $input, OutputInterface $outp $this->paths = $this->fixturesConfig; $output->writeln(sprintf('%s', "Loading path from configuration file.")); - }elseif (empty($this->paths)) { + } + + if (empty($this->paths)) { $output->writeln(sprintf('%s', "Detecting fixture in application.")); $this->paths = $this->findFixtureInApplication(); diff --git a/src/DoctrineMongoODMDatafixture/Module.php b/src/DoctrineMongoODMDatafixture/Module.php index bfaa322..d438113 100644 --- a/src/DoctrineMongoODMDatafixture/Module.php +++ b/src/DoctrineMongoODMDatafixture/Module.php @@ -10,7 +10,7 @@ class Module { - const VERSION = '1.0'; + const VERSION = '1.2'; public function getConfig() { @@ -36,9 +36,12 @@ public function init(ModuleManagerInterface $manager) */ public function loadCli(EventInterface $event) { + $config = $event->getParam('ServiceManager')->get('config'); + $fixturesConfig = (isset($config['odm-data-fixtures']))? $config['odm-data-fixtures'] : null; + $commands = array( - new \DoctrineMongoODMDatafixture\Command\DoctrineMongoODMDatafixtureCommand(), - new \DoctrineMongoODMDatafixture\Command\DoctrineMongoODMDatafixtureListCommand() + new \DoctrineMongoODMDatafixture\Command\DoctrineMongoODMDatafixtureCommand($fixturesConfig), + new \DoctrineMongoODMDatafixture\Command\DoctrineMongoODMDatafixtureListCommand($fixturesConfig) ); foreach ($commands as $command) { @@ -64,4 +67,5 @@ public function loadCli(EventInterface $event) $cli->getHelperSet()->set($documentHelper, 'dm'); $cli->getHelperSet()->set(new QuestionHelper(), 'question'); } + }