Neos\Flow\Reflection\ReflectionService::getClassAnnotations PHP 메소드

getClassAnnotations() 공개 메소드

Returns the specified class annotations or an empty array
public getClassAnnotations ( string $className, string $annotationClassName = null ) : array
$className string Name of the class
$annotationClassName string Annotation to filter for
리턴 array
    public function getClassAnnotations($className, $annotationClassName = null)
    {
        $className = $this->prepareClassReflectionForUsage($className);
        $annotationClassName = $annotationClassName === null ? null : $this->cleanClassName($annotationClassName);
        if (!isset($this->classReflectionData[$className][self::DATA_CLASS_ANNOTATIONS])) {
            return [];
        }
        if ($annotationClassName === null) {
            return $this->classReflectionData[$className][self::DATA_CLASS_ANNOTATIONS];
        }
        $annotations = [];
        foreach ($this->classReflectionData[$className][self::DATA_CLASS_ANNOTATIONS] as $annotation) {
            if ($annotation instanceof $annotationClassName) {
                $annotations[] = $annotation;
            }
        }
        return $annotations;
    }

Usage Example

 /**
  * Builds the class documentation block for the specified class keeping doc comments and vital annotations
  *
  * @return string $methodDocumentation DocComment for the given method
  */
 protected function buildClassDocumentation()
 {
     $classDocumentation = "/**\n";
     $classReflection = new ClassReflection($this->fullOriginalClassName);
     $classDescription = $classReflection->getDescription();
     $classDocumentation .= ' * ' . str_replace("\n", "\n * ", $classDescription) . "\n";
     foreach ($this->reflectionService->getClassAnnotations($this->fullOriginalClassName) as $annotation) {
         $classDocumentation .= ' * ' . Compiler::renderAnnotation($annotation) . "\n";
     }
     $classDocumentation .= " */\n";
     return $classDocumentation;
 }
All Usage Examples Of Neos\Flow\Reflection\ReflectionService::getClassAnnotations
ReflectionService