This commit is contained in:
Maxime Renou 2019-03-19 14:49:29 +01:00
parent 830dff92a2
commit 2dbcc322f1
1 changed files with 3 additions and 5 deletions

View File

@ -44,9 +44,7 @@ class Storage
protected function getStorageAnnotation($entity, $attribute) protected function getStorageAnnotation($entity, $attribute)
{ {
$reflectionEntity = new \ReflectionObject($entity); $reflection = new \ReflectionProperty($entity, $attribute);
$reflection = $reflectionEntity->getProperty($attribute);
$reflection->setAccessible(true);
$reader = new AnnotationReader(); $reader = new AnnotationReader();
$annotations = $reader->getPropertyAnnotations($reflection); $annotations = $reader->getPropertyAnnotations($reflection);
@ -74,9 +72,9 @@ class Storage
return $annotation->name; 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); $storage = $this->get($annotation->name);
$prefix = is_null($annotation->prefix) || empty($annotation->prefix) ? '' : trim($annotation->prefix, '/').'/'; $prefix = is_null($annotation->prefix) || empty($annotation->prefix) ? '' : trim($annotation->prefix, '/').'/';
$camel = ucfirst(Container::camelize($attribute)); $camel = ucfirst(Container::camelize($attribute));