浏览代码

Fixed problem with multiple occurences of a given namespace. fix #2688

David Christmann 13 年之前
父节点
当前提交
4a8f101b9d
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php

+ 4 - 1
src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php

@@ -112,8 +112,11 @@ EOT
                 $basename = substr($m->name, strrpos($m->name, '\\') + 1);
                 $output->writeln(sprintf('  > backing up <comment>%s.php</comment> to <comment>%s.php~</comment>', $basename, $basename));
             }
+            // Getting the metadata for the entity class once more to get the correct path if the namespace has multiple occurrences
+            $entityMetadata = $manager->getClassMetadata($m->getName(), $input->getOption('path'));
+
             $output->writeln(sprintf('  > generating <comment>%s</comment>', $m->name));
-            $generator->generate(array($m), $metadata->getPath());
+            $generator->generate(array($m), $entityMetadata->getPath());
 
             if ($m->customRepositoryClassName && false !== strpos($m->customRepositoryClassName, $metadata->getNamespace())) {
                 $repoGenerator->writeEntityRepositoryClass($m->customRepositoryClassName, $metadata->getPath());