Doctrine\Common\Annotations\AnnotationReader::getMethodAnnotation PHP Méthode

getMethodAnnotation() public méthode

{@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

 /**
  * Generate Remote API from a list of controllers
  */
 public function generateRemotingApi()
 {
     $list = array();
     foreach ($this->remotingBundles as $bundle) {
         $bundleRef = new \ReflectionClass($bundle);
         $controllerDir = new Finder();
         $controllerDir->files()->in(dirname($bundleRef->getFileName()) . '/Controller/')->name('/.*Controller\\.php$/');
         foreach ($controllerDir as $controllerFile) {
             /** @var SplFileInfo $controllerFile */
             $controller = $bundleRef->getNamespaceName() . "\\Controller\\" . substr($controllerFile->getFilename(), 0, -4);
             $controllerRef = new \ReflectionClass($controller);
             foreach ($controllerRef->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
                 /** @var $methodDirectAnnotation Direct */
                 $methodDirectAnnotation = $this->annoReader->getMethodAnnotation($method, 'Tpg\\ExtjsBundle\\Annotation\\Direct');
                 if ($methodDirectAnnotation !== null) {
                     $nameSpace = str_replace("\\", ".", $bundleRef->getNamespaceName());
                     $className = str_replace("Controller", "", $controllerRef->getShortName());
                     $methodName = str_replace("Action", "", $method->getName());
                     $list[$nameSpace][$className][] = array('name' => $methodName, 'len' => count($method->getParameters()));
                 }
             }
         }
     }
     return $list;
 }
All Usage Examples Of Doctrine\Common\Annotations\AnnotationReader::getMethodAnnotation