Nette\Reflection\ClassType::getAnnotations PHP Метод

getAnnotations() публичный Метод

Returns all annotations.
public getAnnotations ( ) : Nette\Reflection\IAnnotation[][]
Результат Nette\Reflection\IAnnotation[][]
    public function getAnnotations()
    {
        return AnnotationsParser::getAll($this);
    }

Usage Example

Пример #1
0
 /**
  * Parses class annotation and build metadata object
  * 
  * @param Nette\Reflection\ClassType $reflection 
  * @throws vBuilder\InvalidAnnotationException if any annotation is missing or bad formed
  */
 public function __construct(Nette\Reflection\ClassType $reflection)
 {
     // Nazev tabulky
     $annotations = $reflection->getAnnotations();
     if (isset($annotations['Table']) && isset($annotations['Table'][0]['name'])) {
         $this->tableName = $annotations['Table'][0]['name'];
     }
     // Entitni chovani
     if (isset($annotations['Behavior'])) {
         foreach ($annotations['Behavior'] as $curr) {
             if (!is_array($curr) && !$curr instanceof \Traversable) {
                 $this->behaviors[$curr] = array();
                 continue;
             }
             $curr = (array) $curr;
             $this->behaviors[array_shift($curr)] = $curr;
         }
     }
     // Sloupecky
     if (isset($annotations['Column'])) {
         foreach ($annotations['Column'] as $curr) {
             // Prazdne definice
             if ($curr === true) {
                 continue;
             }
             if (!is_array($curr) && !$curr instanceof \Traversable) {
                 $this->fields[$curr] = array();
                 continue;
             }
             $curr = (array) $curr;
             $name = array_shift($curr);
             $this->fields[$name] = array();
             foreach ($curr as $k => $v) {
                 if (is_numeric($k)) {
                     $this->fields[$name][$v] = true;
                 } else {
                     $this->fields[$name][$k] = $v;
                 }
             }
             if (isset($this->fields[$name]['id']) || isset($this->fields[$name]['pk'])) {
                 $this->idFields[] = $name;
             }
         }
     }
 }
All Usage Examples Of Nette\Reflection\ClassType::getAnnotations