Selaa lähdekoodia

#2688: Entities are generated in wrong folder (doctrine:generate:entities Namespace)

Arno Geurts 13 vuotta sitten
vanhempi
commit
0900ecc895

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

@@ -113,7 +113,12 @@ EOT
                 $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'));
+            try {
+                $entityMetadata = $manager->getClassMetadata($m->getName(), $input->getOption('path'));
+            } catch(\RuntimeException $e) {
+                // fall back to the bundle metadata when no entity class could be found
+                $entityMetadata = $metadata;
+            }
 
             $output->writeln(sprintf('  > generating <comment>%s</comment>', $m->name));
             $generator->generate(array($m), $entityMetadata->getPath());