Skip to content

Commit

Permalink
Fix potential issue with proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
maxiloc committed Dec 7, 2015
1 parent 9c25661 commit 642cab5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Indexer/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,17 @@ public function getMetaDataLoader()
return new AnnotationLoader();
}

private function removeProxy($class)
{
/* Avoid proxy class form symfony */
return str_replace("Proxies\\__CG__\\", "", $class);
}

private function get_class($entity)
{
$class = get_class($entity);

/* Avoid proxy class form symfony */
$class = str_replace("Proxies\\__CG__\\", "", $class);
$class = $this->removeProxy($class);

return $class;
}
Expand All @@ -140,6 +145,7 @@ public function discoverEntity($entity_or_class, EntityManager $em)
$class = $this->get_class($entity);
} else {
$class = $em->getRepository($entity_or_class)->getClassName();
$class = $this->removeProxy($class);
$reflClass = new \ReflectionClass($class);

if ($reflClass->isAbstract()) {
Expand Down
8 changes: 8 additions & 0 deletions Mapping/Loader/AnnotationLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,21 @@ protected function getAnnotationReader()
return self::$annotationReader;
}

private function removeProxy($class)
{
/* Avoid proxy class form symfony */
return str_replace("Proxies\\__CG__\\", "", $class);
}

/**
* @return Description
*/
public function getMetaData($entity, EntityManager $em)
{
$class = get_class($entity);

$class = $this->removeProxy($class);

$description = new Description($class);

$refl = new \ReflectionClass($entity);
Expand Down

0 comments on commit 642cab5

Please sign in to comment.