From 642cab5b96ad41d967a24a044406dafad19b20bd Mon Sep 17 00:00:00 2001 From: Maxime Locqueville Date: Mon, 7 Dec 2015 12:11:13 +0100 Subject: [PATCH] Fix potential issue with proxies --- Indexer/Indexer.php | 10 ++++++++-- Mapping/Loader/AnnotationLoader.php | 8 ++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Indexer/Indexer.php b/Indexer/Indexer.php index a0ce2c03..7d1f97b1 100644 --- a/Indexer/Indexer.php +++ b/Indexer/Indexer.php @@ -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; } @@ -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()) { diff --git a/Mapping/Loader/AnnotationLoader.php b/Mapping/Loader/AnnotationLoader.php index 03ceee54..58f2f0c4 100644 --- a/Mapping/Loader/AnnotationLoader.php +++ b/Mapping/Loader/AnnotationLoader.php @@ -40,6 +40,12 @@ protected function getAnnotationReader() return self::$annotationReader; } + private function removeProxy($class) + { + /* Avoid proxy class form symfony */ + return str_replace("Proxies\\__CG__\\", "", $class); + } + /** * @return Description */ @@ -47,6 +53,8 @@ public function getMetaData($entity, EntityManager $em) { $class = get_class($entity); + $class = $this->removeProxy($class); + $description = new Description($class); $refl = new \ReflectionClass($entity);