Permalink
Browse files

[DoctrineBundle] added Registry::getEntityManagers()

  • Loading branch information...
1 parent ab2556c commit ceb786c68e9921981defc039882977d2e43f5d94 @fabpot fabpot committed Jun 7, 2011
Showing with 18 additions and 4 deletions.
  1. +1 −2 CacheWarmer/ProxyCacheWarmer.php
  2. +2 −2 Mapping/MetadataFactory.php
  3. +15 −0 Registry.php
@@ -64,8 +64,7 @@ public function warmUp($cacheDir)
return;
}
- foreach ($this->container->get('doctrine')->getEntityManagerNames() as $id) {
- $em = $this->container->get($id);
+ foreach ($this->container->get('doctrine')->getEntityManagers() as $em) {
$classes = $em->getMetadataFactory()->getAllMetadata();
$em->getProxyFactory()->generateProxyClasses($classes);
}
@@ -156,9 +156,9 @@ private function getMetadataForClass($entity)
private function getAllMetadata()
{
$metadata = array();
- foreach ($this->registry->getEntityManagerNames() as $name => $id) {
+ foreach ($this->registry->getEntityManagers() as $em) {
$cmf = new DisconnectedClassMetadataFactory();
- $cmf->setEntityManager($this->registry->getEntityManager($name));
+ $cmf->setEntityManager($em);
foreach ($cmf->getAllMetadata() as $m) {
$metadata[] = $m;
}
View
@@ -124,6 +124,21 @@ public function getEntityManager($name = null)
}
/**
+ * Gets an array of all registered entity managers
+ *
+ * @return array An array of EntityManager instances
+ */
+ public function getEntityManagers()
+ {
+ $ems = array();
+ foreach ($this->entityManagers as $name => $id) {
+ $ems[$name] = $this->container->get($id);
+ }
+
+ return $ems;
+ }
+
+ /**
* Resets a named entity manager.
*
* This method is useful when an entity manager has been closed

0 comments on commit ceb786c

Please sign in to comment.