[DoctrineBundle] Fix getBundleMetadata helper function in DoctrineCommand
This commit is contained in:
parent
92ddaa11cd
commit
394a60b4be
@ -131,12 +131,20 @@ abstract class DoctrineCommand extends Command
|
|||||||
return $entityManagers;
|
return $entityManagers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getDoctrineEntityManagers()
|
||||||
|
{
|
||||||
|
$entityManagerNames = $this->container->getParameter('doctrine.orm.entity_managers');
|
||||||
|
$entityManagers = array();
|
||||||
|
foreach ($entityManagerNames AS $entityManagerName) {
|
||||||
|
$em = $this->container->get(sprintf('doctrine.orm.%s_entity_manager', $entityManagerName));
|
||||||
|
$entityManagers[] = $em;
|
||||||
|
}
|
||||||
|
return $entityManagers;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getBundleMetadatas(Bundle $bundle)
|
protected function getBundleMetadatas(Bundle $bundle)
|
||||||
{
|
{
|
||||||
$tmp = dirname(str_replace('\\', '/', get_class($bundle)));
|
|
||||||
$namespace = $bundle->getNamespace();
|
$namespace = $bundle->getNamespace();
|
||||||
$class = basename($tmp);
|
|
||||||
|
|
||||||
$bundleMetadatas = array();
|
$bundleMetadatas = array();
|
||||||
$entityManagers = $this->getDoctrineEntityManagers();
|
$entityManagers = $this->getDoctrineEntityManagers();
|
||||||
foreach ($entityManagers as $key => $em) {
|
foreach ($entityManagers as $key => $em) {
|
||||||
@ -144,7 +152,6 @@ abstract class DoctrineCommand extends Command
|
|||||||
$cmf->setEntityManager($em);
|
$cmf->setEntityManager($em);
|
||||||
$metadatas = $cmf->getAllMetadata();
|
$metadatas = $cmf->getAllMetadata();
|
||||||
foreach ($metadatas as $metadata) {
|
foreach ($metadatas as $metadata) {
|
||||||
|
|
||||||
if (strpos($metadata->name, $namespace) === 0) {
|
if (strpos($metadata->name, $namespace) === 0) {
|
||||||
$bundleMetadatas[$metadata->name] = $metadata;
|
$bundleMetadatas[$metadata->name] = $metadata;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user