Nette\Reflection\ClassType::getProperties PHP Method

getProperties() public method

public getProperties ( $filter ) : Property[]
return Property[]
    public function getProperties($filter = -1)
    {
        foreach ($res = parent::getProperties($filter) as $key => $val) {
            $res[$key] = new Property($this->getName(), $val->getName());
        }
        return $res;
    }

Usage Example

Beispiel #1
0
 /**
  * @param \Nette\DI\Container $dic
  * @throws MemberAccessException
  * @throws MissingServiceException
  * @throws InvalidStateException
  * @throws UnexpectedValueException
  */
 public function injectProperties(Nette\DI\Container $dic)
 {
     if (!$this instanceof Nette\Application\UI\PresenterComponent && !$this instanceof Nette\Application\UI\Component) {
         throw new MemberAccessException('Trait ' . __TRAIT__ . ' can be used only in descendants of PresenterComponent.');
     }
     $this->autowirePropertiesLocator = $dic;
     $storage = $dic->hasService('autowired.cacheStorage') ? $dic->getService('autowired.cacheStorage') : $dic->getByType('Nette\\Caching\\IStorage');
     $cache = new Nette\Caching\Cache($storage, 'Kdyby.Autowired.AutowireProperties');
     $containerFileName = ClassType::from($this->autowirePropertiesLocator)->getFileName();
     $cacheKey = [$presenterClass = get_class($this), $containerFileName];
     if (is_array($this->autowireProperties = $cache->load($cacheKey))) {
         foreach ($this->autowireProperties as $propName => $tmp) {
             unset($this->{$propName});
         }
         return;
     }
     $this->autowireProperties = [];
     $ignore = class_parents('Nette\\Application\\UI\\Presenter') + ['ui' => 'Nette\\Application\\UI\\Presenter'];
     $rc = new ClassType($this);
     foreach ($rc->getProperties() as $prop) {
         if (!$this->validateProperty($prop, $ignore)) {
             continue;
         }
         $this->resolveProperty($prop);
     }
     $files = array_map(function ($class) {
         return ClassType::from($class)->getFileName();
     }, array_diff(array_values(class_parents($presenterClass) + ['me' => $presenterClass]), $ignore));
     $files[] = $containerFileName;
     $cache->save($cacheKey, $this->autowireProperties, [$cache::FILES => $files]);
 }
All Usage Examples Of Nette\Reflection\ClassType::getProperties