Doctrine\Common\Annotations\FileCacheReader::getMethodAnnotation PHP Method

getMethodAnnotation() public method

{@inheritDoc}
public getMethodAnnotation ( ReflectionMethod $method, $annotationName )
$method ReflectionMethod
    public function getMethodAnnotation(\ReflectionMethod $method, $annotationName)
    {
        $annotations = $this->getMethodAnnotations($method);
        foreach ($annotations as $annotation) {
            if ($annotation instanceof $annotationName) {
                return $annotation;
            }
        }
        return null;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Listen kernel.controller event for find assigned annotation
  * 
  * @param FilterControllerEvent $event
  * @return null
  */
 public function onKernelController(FilterControllerEvent $event)
 {
     $controller = $event->getController();
     if (!is_array($controller)) {
         return;
     }
     $action = new ReflectionMethod($controller[0], $controller[1]);
     $annotation = $this->annotationReader->getMethodAnnotation($action, $this->annotationClass);
     if (get_class($annotation) != $this->annotationClass) {
         return;
     }
     $newController = $this->resolver->resolve($annotation);
     if (!empty($newController)) {
         $event->setController($newController);
     }
 }