Nette\DI\ServiceDefinition::setSetup PHP Метод

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

public setSetup ( array $setup ) : self
$setup array
Результат self
    public function setSetup(array $setup)
    {
        foreach ($setup as $v) {
            if (!$v instanceof Statement) {
                throw new Nette\InvalidArgumentException('Argument must be Nette\\DI\\Statement[].');
            }
        }
        $this->setup = $setup;
        return $this;
    }

Usage Example

Пример #1
0
 private function updateDefinition(DI\ServiceDefinition $def)
 {
     $class = $def->getClass();
     $setups = $def->getSetup();
     foreach (self::getInjectProperties($class) as $property => $type) {
         $builder = $this->getContainerBuilder();
         $inject = new DI\Statement('$' . $property, ['@\\' . ltrim($type, '\\')]);
         foreach ($setups as $key => $setup) {
             if ($setup->getEntity() === $inject->getEntity()) {
                 $inject = $setup;
                 $builder = NULL;
                 unset($setups[$key]);
             }
         }
         self::checkType($class, $property, $type, $builder);
         array_unshift($setups, $inject);
     }
     foreach (array_reverse(self::getInjectMethods($def->getClass())) as $method) {
         $inject = new DI\Statement($method);
         foreach ($setups as $key => $setup) {
             if ($setup->getEntity() === $inject->getEntity()) {
                 $inject = $setup;
                 unset($setups[$key]);
             }
         }
         array_unshift($setups, $inject);
     }
     $def->setSetup($setups);
 }
All Usage Examples Of Nette\DI\ServiceDefinition::setSetup