Skip to content

Commit

Permalink
[DoctrineBundle] renamed RegistryInterface::getEntityManagerForObject…
Browse files Browse the repository at this point in the history
…() to getEntityManagerForClass()
  • Loading branch information
fabpot committed Jul 19, 2011
1 parent 9e7cb0a commit d3a69e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/Symfony/Bridge/Doctrine/RegistryInterface.php
Expand Up @@ -125,11 +125,11 @@ function getEntityManagerNames();
function getRepository($entityName, $entityManagerName = null);

/**
* Gets the entity manager associated with a given object.
* Gets the entity manager associated with a given class.
*
* @param object $object A Doctrine Entity
* @param string $class A Doctrine Entity class name
*
* @return EntityManager|null
*/
function getEntityManagerForObject($object);
function getEntityManagerForClass($class);
}
Expand Up @@ -32,7 +32,7 @@ public function __construct(RegistryInterface $registry)
public function initialize($object)
{
if ($object instanceof Proxy) {
$this->registry->getEntityManagerForObject($object)->getUnitOfWork()->initializeObject($object);
$this->registry->getEntityManagerForClass(get_class($object))->getUnitOfWork()->initializeObject($object);
}
}
}
13 changes: 5 additions & 8 deletions src/Symfony/Bundle/DoctrineBundle/Registry.php
Expand Up @@ -16,7 +16,6 @@
use Doctrine\DBAL\Connection;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\ORMException;
use Doctrine\ORM\Proxy\Proxy;

/**
* References all Doctrine connections and entity managers in a given Container.
Expand Down Expand Up @@ -219,19 +218,17 @@ public function getRepository($entityName, $entityManagerName = null)
}

/**
* Gets the entity manager associated with a given object.
* Gets the entity manager associated with a given class.
*
* @param object $object A Doctrine Entity
* @param string $class A Doctrine Entity class name
*
* @return EntityManager|null
*/
public function getEntityManagerForObject($object)
public function getEntityManagerForClass($class)
{
if ($object instanceof Proxy) {
$proxyClass = new \ReflectionClass($object);
$proxyClass = new \ReflectionClass($class);
if ($proxyClass->implementsInterface('Doctrine\ORM\Proxy\Proxy')) {
$class = $proxyClass->getParentClass()->getName();
} else {
$class = get_class($object);
}

foreach ($this->entityManagers as $id) {
Expand Down

0 comments on commit d3a69e3

Please sign in to comment.