Doctrine\Common\Annotations\CachedReader::getPropertyAnnotation PHP Method

getPropertyAnnotation() public method

{@inheritDoc}
public getPropertyAnnotation ( ReflectionProperty $property, $annotationName )
$property ReflectionProperty
    public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName)
    {
        foreach ($this->getPropertyAnnotations($property) as $annot) {
            if ($annot instanceof $annotationName) {
                return $annot;
            }
        }
        return null;
    }

Usage Example

Beispiel #1
0
 /**
  * Получает список параметров для которых определена аннотация $ann_name
  * @param mixed $object
  * @param callable $cb function($annotation_class,$propery_name){}
  */
 public function getFields($object, $annotation_class, callable $cb)
 {
     $reflClass = new \ReflectionClass($object);
     $props = $reflClass->getProperties();
     foreach ($props as $prop) {
         $annotation = $this->annotation_reader->getPropertyAnnotation($prop, $annotation_class);
         if (is_null($annotation)) {
             continue;
         }
         $cb($annotation, $prop->name);
     }
 }
All Usage Examples Of Doctrine\Common\Annotations\CachedReader::getPropertyAnnotation