コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function invoke(callable $callable, $requestObject)
 {
     /** @var Attribute $attributeAnnotation */
     $attributeAnnotation = $this->annotationReader->getMethodAnnotation(ReflectionFunctionFactory::createReflectionMethodFromCallable($callable), Attribute::class);
     $attributeName = $attributeAnnotation->name;
     $attributeValue = $this->propertyAccessor->getValue($requestObject, $attributeAnnotation->valueAt);
     $userId = $this->userProvider->getUserId();
     if (!is_array($attributeValue) && !$this->guard->isGranted($userId, $attributeName, $attributeValue)) {
         throw new AccessDeniedException();
     }
     if (is_array($attributeValue)) {
         $attributeValue = $this->guard->filterGranted($userId, $attributeName, $attributeValue);
         $this->propertyAccessor->setValue($requestObject, $attributeAnnotation->valueAt, $attributeValue);
     }
     return $this->methodInvoker->invoke($callable, $requestObject);
 }