8000 [DoctrineBundle] renamed RegistryInterface::getEntityManagerForObject… · yktd26/symfony@d3a69e3 · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit d3a69e3

Browse files
committed
[DoctrineBundle] renamed RegistryInterface::getEntityManagerForObject() to getEntityManagerForClass()
1 parent 9e7cb0a commit d3a69e3

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

src/Symfony/Bridge/Doctrine/RegistryInterface.php

Lines changed: 3 additions & 3 deletions
10000
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ function getEntityManagerNames();
125125
function getRepository($entityName, $entityManagerName = null);
126126

127127
/**
128-
* Gets the entity manager associated with a given object.
128+
* Gets the entity manager associated with a given class.
129129
*
130-
* @param object $object A Doctrine Entity
130+
* @param string $class A Doctrine Entity class name
131131
*
132132
* @return EntityManager|null
133133
*/
134-
function getEntityManagerForObject($object);
134+
function getEntityManagerForClass($class);
135135
}

src/Symfony/Bridge/Doctrine/Validator/EntityInitializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(RegistryInterface $registry)
3232
public function initialize($object)
3333
{
3434
if ($object instanceof Proxy) {
35-
$this->registry->getEntityManagerForObject($object)->getUnitOfWork()->initializeObject($object);
35+
$this->registry->getEntityManagerForClass(get_class($object))->getUnitOfWork()->initializeObject($object);
3636
}
3737
}
3838
}

src/Symfony/Bundle/DoctrineBundle/Registry.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Doctrine\DBAL\Connection;
1717
use Doctrine\ORM\Configuration;
1818
use Doctrine\ORM\ORMException;
19-
use Doctrine\ORM\Proxy\Proxy;
2019

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

221220
/**
222-
* Gets the entity manager associated with a given object.
221+
* Gets the entity manager associated with a given class.
223222
*
224-
* @param object $object A Doctrine Entity
223+
* @param string $class A Doctrine Entity class name
225224
*
226225
* @return EntityManager|null
227226
*/
228-
public function getEntityManagerForObject($object)
227+
public function getEntityManagerForClass($class)
229228
{
230-
if ($object instanceof Proxy) {
231-
$proxyClass = new \ReflectionClass($object);
229+
$proxyClass = new \ReflectionClass($class);
230+
if ($proxyClass->implementsInterface('Doctrine\ORM\Proxy\Proxy')) {
232231
$class = $proxyClass->getParentClass()->getName();
233-
} else {
234-
$class = get_class($object);
235232
}
236233

237234
foreach ($this->entityManagers as $id) {

0 commit comments

Comments
 (0)
0