From f2d9faee591252d204fa5d6e713860a51c13831d Mon Sep 17 00:00:00 2001 From: Jesus Manuel Olivas Date: Fri, 31 Oct 2014 11:27:31 -0700 Subject: [PATCH 1/4] Add getEntityManager method --- src/Command/ContainerAwareCommand.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Command/ContainerAwareCommand.php b/src/Command/ContainerAwareCommand.php index b258188a5..b8f867865 100644 --- a/src/Command/ContainerAwareCommand.php +++ b/src/Command/ContainerAwareCommand.php @@ -97,6 +97,10 @@ public function getConfigStorage(){ return $this->getContainer()->get('config.storage'); } + public function getEntityManager(){ + return $this->getContainer()->get('entity.manager'); + } + public function validateModuleExist($module_name) { return $this->getValidator()->validateModuleExist($module_name, $this->getModules()); From b99c9fca7ed928096a09a2886156bd142ec29027 Mon Sep 17 00:00:00 2001 From: Jesus Manuel Olivas Date: Fri, 31 Oct 2014 11:27:55 -0700 Subject: [PATCH 2/4] Update validateMachineName method --- src/Command/ContainerAwareCommand.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Command/ContainerAwareCommand.php b/src/Command/ContainerAwareCommand.php index b8f867865..9d16e9769 100644 --- a/src/Command/ContainerAwareCommand.php +++ b/src/Command/ContainerAwareCommand.php @@ -141,7 +141,13 @@ public function validateClassName($class_name) public function validateMachineName($machine_name) { - return $this->getValidator()->validateMachineName($machine_name); + $machine_name = $this->getValidator()->validateMachineName($machine_name); + + if ($this->getEntityManager()->hasDefinition($machine_name)) { + throw new \InvalidArgumentException(sprintf('Machine name "%s" is duplicated.', $machine_name)); + } + + return $machine_name; } /** From c528b50b5fd60ffab44e0dcb98cfde1fd2a68d8a Mon Sep 17 00:00:00 2001 From: Jesus Manuel Olivas Date: Fri, 31 Oct 2014 11:28:35 -0700 Subject: [PATCH 3/4] Update interact method --- src/Command/GeneratorEntityCommand.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Command/GeneratorEntityCommand.php b/src/Command/GeneratorEntityCommand.php index 20cfa7010..6799b5ab9 100644 --- a/src/Command/GeneratorEntityCommand.php +++ b/src/Command/GeneratorEntityCommand.php @@ -103,13 +103,18 @@ protected function interact(InputInterface $input, OutputInterface $output) // --entity-name option $entity_name = $input->getOption('entity-name'); if (!$entity_name) { - $entity_name = $dialog->ask( - $output, - $dialog->getQuestion('Enter the entity name', $machine_name), - $machine_name, - null + $entity_name = $dialog->askAndValidate( + $output, + $dialog->getQuestion('Enter the entity name', $machine_name), + function ($machine_name) { + return $this->validateMachineName($machine_name); + }, + false, + $machine_name, + null ); } + $input->setOption('entity-name', $entity_name); } From 7b3d29d10c722261222d646629ac3a2848f3a4c2 Mon Sep 17 00:00:00 2001 From: Jesus Manuel Olivas Date: Fri, 31 Oct 2014 11:38:32 -0700 Subject: [PATCH 4/4] Upadate Twig version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 99b741c78..cd2cedb7b 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "symfony/console": "2.5.*", "symfony/finder": "2.5.*", "symfony/dependency-injection": "2.5.*", - "twig/twig": "1.15.*", + "twig/twig": "1.16.*", "composer/installers": "~1.0" }, "require-dev": {