Skip to content

Commit

Permalink
Fixed problem with multiple occurences of a given namespace. fix #2688
Browse files Browse the repository at this point in the history
  • Loading branch information
cim-dch committed Nov 29, 2011
1 parent 2e8fe92 commit 4a8f101
Showing 1 changed file with 4 additions and 1 deletion.
Expand Up @@ -112,8 +112,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
$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());
Expand Down

4 comments on commit 4a8f101

@arnogeurts
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got an error while generating my entities, due to this commit. This piece of code tries to get the class metadata of the entity object. As long as this entity does not exist yet, the manager will throw an exception.

Are you sure this is the right way to fix the problem?

@DavidChristmann
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your reply, I will have a look at it.

@arnogeurts
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just committed a fix that worked for me, maybe you can take a look at it before i send a pull request:
https://github.com/arnogeurts/symfony/blob/PR-2688/src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php

@DavidChristmann
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with your code.

Please sign in to comment.