Skip to content

Commit

Permalink
[DoctrineBundle] fixed doctrine:generate:entities
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed May 4, 2011
1 parent c200b42 commit ec226cd
Showing 1 changed file with 9 additions and 7 deletions.
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\Tools\EntityRepositoryGenerator;

/**
* Generate entity classes from mapping information
Expand Down Expand Up @@ -58,7 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$bundle = $this->getApplication()->getKernel()->getBundle($input->getArgument('name'));

$output->writeln(sprintf('Generating entities for bundle "<info>%s</info>"', $bundle->getName()));
list($metadatas, $path) = $this->getBundleInfo($bundle);
list($metadatas, $namespace, $path) = $this->getBundleInfo($bundle);
} catch (\InvalidArgumentException $e) {
$name = strtr($input->getArgument('name'), '/', '\\');

Expand All @@ -68,14 +69,15 @@ protected function execute(InputInterface $input, OutputInterface $output)

if (class_exists($name)) {
$output->writeln(sprintf('Generating entity "<info>%s</info>"', $name));
list($metadatas, $path) = $this->getClassInfo($name);
list($metadatas, $namespace, $path) = $this->getClassInfo($name);
} else {
$output->writeln(sprintf('Generating entities for namespace "<info>%s</info>"', $name));
list($metadatas, $path) = $this->getNamespaceInfo($name);
list($metadatas, $namespace, $path) = $this->getNamespaceInfo($name);
}
}

$generator = $this->getEntityGenerator();
$repoGenerator = new EntityRepositoryGenerator();
foreach ($metadatas as $metadata) {
$output->writeln(sprintf(' > generating <comment>%s</comment>', $metadata->name));
$generator->generate(array($metadata), $path);
Expand All @@ -85,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
continue;
}

$generator->writeEntityRepositoryClass($metadata->customRepositoryClassName, $path);
$repoGenerator->writeEntityRepositoryClass($metadata->customRepositoryClassName, $path);
}
}
}
Expand All @@ -99,7 +101,7 @@ private function getBundleInfo($bundle)

$path = $this->findBasePathForClass($bundle->getName(), $bundle->getNamespace(), $bundle->getPath());

return array($metadatas, $path);
return array($metadatas, $bundle->getNamespace(), $path);
}

private function getClassInfo($class)
Expand All @@ -114,7 +116,7 @@ private function getClassInfo($class)
}
$path = $this->findBasePathForClass($class, $r->getNamespacename(), dirname($r->getFilename()));

return array($metadatas, $path);
return array($metadatas, $r->getNamespacename(), $path);
}

private function getNamespaceInfo($namespace)
Expand All @@ -130,6 +132,6 @@ private function getNamespaceInfo($namespace)
}
$path = $this->findBasePathForClass($namespace, $r->getNamespacename(), dirname($r->getFilename()));

return array($metadatas, $path);
return array($metadatas, $namespace, $path);
}
}

0 comments on commit ec226cd

Please sign in to comment.