Skip to content

Commit

Permalink
DCOM-93 - Adjust ClassMetadataFactory#getClassParents() to use reflec…
Browse files Browse the repository at this point in the history
…tion service.
  • Loading branch information
beberlei committed Jan 2, 2012
1 parent 87e0c69 commit 9bdf9a9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
32 changes: 31 additions & 1 deletion lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
Doctrine\ORM\EntityManager,
Doctrine\DBAL\Platforms,
Doctrine\ORM\Events,
Doctrine\Common\Persistence\Mapping\RuntimeReflectionService,
Doctrine\Common\Persistence\Mapping\ReflectionService,
Doctrine\Common\Persistence\Mapping\ClassMetadataFactory as ClassMetadataFactoryInterface;

/**
Expand Down Expand Up @@ -74,6 +76,11 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
*/
private $initialized = false;

/**
* @var ReflectionException
*/
private $reflectionService;

/**
* @param EntityManager $$em
*/
Expand Down Expand Up @@ -220,7 +227,7 @@ protected function getParentClasses($name)
{
// Collect parent classes, ignoring transient (not-mapped) classes.
$parentClasses = array();
foreach (array_reverse(class_parents($name)) as $parentClass) {
foreach (array_reverse($this->getReflectionService()->getParentClasses($name)) as $parentClass) {
if ( ! $this->driver->isTransient($parentClass)) {
$parentClasses[] = $parentClass;
}
Expand Down Expand Up @@ -533,4 +540,27 @@ public function isTransient($class)

return $this->driver->isTransient($class);
}

/**
* Get reflectionService.
*
* @return \Doctrine\Common\Persistence\Mapping\ReflectionService
*/
public function getReflectionService()
{
if ($this->reflectionService === null) {
$this->reflectionService = new RuntimeReflectionService();
}
return $this->reflectionService;
}

/**
* Set reflectionService.
*
* @param reflectionService the value to set.
*/
public function setReflectionService(ReflectionService $reflectionService)
{
$this->reflectionService = $reflectionService;
}
}

0 comments on commit 9bdf9a9

Please sign in to comment.