From 2dbcc322f126a7aa5a269bdb8a053fa5c02ee637 Mon Sep 17 00:00:00 2001 From: Maxime Renou Date: Tue, 19 Mar 2019 14:49:29 +0100 Subject: [PATCH] Fix --- StorageBundle/Storage.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/StorageBundle/Storage.php b/StorageBundle/Storage.php index c617baa..9a6518e 100644 --- a/StorageBundle/Storage.php +++ b/StorageBundle/Storage.php @@ -44,9 +44,7 @@ class Storage protected function getStorageAnnotation($entity, $attribute) { - $reflectionEntity = new \ReflectionObject($entity); - $reflection = $reflectionEntity->getProperty($attribute); - $reflection->setAccessible(true); + $reflection = new \ReflectionProperty($entity, $attribute); $reader = new AnnotationReader(); $annotations = $reader->getPropertyAnnotations($reflection); @@ -74,9 +72,9 @@ class Storage return $annotation->name; } - public function url($entity, $attribute) + public function url($entity, $attribute, $class = null) { - $annotation = $this->getStorageAnnotation($entity, $attribute); + $annotation = $this->getStorageAnnotation(!is_null($class) ? $class : $entity, $attribute); $storage = $this->get($annotation->name); $prefix = is_null($annotation->prefix) || empty($annotation->prefix) ? '' : trim($annotation->prefix, '/').'/'; $camel = ucfirst(Container::camelize($attribute));