From e204a1845bbd474c18c3a53ff80499595db1b30f Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 13 Oct 2010 01:04:24 +0200 Subject: [PATCH] [DoctrineBundle] make the task works with vendor bundle namespace --- .../GenerateEntitiesDoctrineCommand.php | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php b/src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php index a6763afd6d31..71a480ac6870 100644 --- a/src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php +++ b/src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php @@ -62,29 +62,28 @@ protected function execute(InputInterface $input, OutputInterface $output) } $entityGenerator = $this->getEntityGenerator(); - $bundleDirs = $this->container->getKernelService()->getBundleDirs(); foreach ($this->container->getKernelService()->getBundles() as $bundle) { - $tmp = dirname(str_replace('\\', '/', get_class($bundle))); - $namespace = str_replace('/', '\\', dirname($tmp)); - $class = basename($tmp); - if ($filterBundle && $filterBundle != $namespace . '\\' . $class) { + // retrieve the full bundle classname + $class = $bundle->getReflection()->getName(); + + if ($filterBundle && $filterBundle != $class) { continue; } - if (isset($bundleDirs[$namespace])) { - $destination = realpath($bundleDirs[$namespace].'/..'); - if ($metadatas = $this->getBundleMetadatas($bundle)) { - $output->writeln(sprintf('Generating entities for "%s"', $class)); + // transform classname to a path and substract it to get the destination + $path = dirname(str_replace('\\', '/', $class)); + $destination = str_replace('/'.$path, "", $bundle->getPath()); - foreach ($metadatas as $metadata) { - if ($filterEntity && strpos($metadata->name, $filterEntity) !== 0) { - continue; - } + if ($metadatas = $this->getBundleMetadatas($bundle)) { + $output->writeln(sprintf('Generating entities for "%s"', $class)); - $output->writeln(sprintf(' > generating %s', $metadata->name)); - $entityGenerator->generate(array($metadata), $destination); + foreach ($metadatas as $metadata) { + if ($filterEntity && strpos($metadata->name, $filterEntity) !== 0) { + continue; } + $output->writeln(sprintf(' > generating %s', $metadata->name)); + $entityGenerator->generate(array($metadata), $destination); } } }