Skip to content

Commit cc66739

Browse files
committed
merged branch DavidChristmann/fix_gen_entities_namespace (PR symfony#2746)
Commits ------- 4a8f101 Fixed problem with multiple occurences of a given namespace. fix symfony#2688 Discussion ---------- [Console] [Doctrine] Fixed: Entities are generated in wrong folder (doctrine:generate:entities Namespace) Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: no Fixes the following tickets: 2688 Todo: - Bug-description: In our project we have some bundles from the same root-namespace "ABC" stored under "vendors/bundles/ABC" and some bundles under "src/ABC". Running the command "$php app/console doctrine:generate:entities ABC" from the commandline generates the entities from "src/ABC/" under "vendors/bundles/ABC/" or vice versa depending on their order in the bundle array in the Appkernel.php. The error does not occur when the entities are generated by bundlename or by classname. Bugfix:-description: Bugfix was to get the path for each entity class once more before generating the entities. Before the bugfix the path was taken form the first entity class of the namespace without checking if the following entities have a different path.
2 parents 654352f + 4a8f101 commit cc66739

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
112112
$basename = substr($m->name, strrpos($m->name, '\\') + 1);
113113
$output->writeln(sprintf(' > backing up <comment>%s.php</comment> to <comment>%s.php~</comment>', $basename, $basename));
114114
}
115+
// Getting the metadata for the entity class once more to get the correct path if the namespace has multiple occurrences
116+
$entityMetadata = $manager->getClassMetadata($m->getName(), $input->getOption('path'));
117+
115118
$output->writeln(sprintf(' > generating <comment>%s</comment>', $m->name));
116-
$generator->generate(array($m), $metadata->getPath());
119+
$generator->generate(array($m), $entityMetadata->getPath());
117120

118121
if ($m->customRepositoryClassName && false !== strpos($m->customRepositoryClassName, $metadata->getNamespace())) {
119122
$repoGenerator->writeEntityRepositoryClass($m->customRepositoryClassName, $metadata->getPath());

0 commit comments

Comments
 (0)