Nette\DI\Extensions\InjectExtension::callInjects PHP Метод

callInjects() публичный статический Метод

Calls all methods starting with with "inject" using autowiring.
public static callInjects ( Container $container, $service ) : void
$container Nette\DI\Container
Результат void
    public static function callInjects(DI\Container $container, $service)
    {
        if (!is_object($service)) {
            throw new Nette\InvalidArgumentException(sprintf('Service must be object, %s given.', gettype($service)));
        }
        foreach (self::getInjectMethods($service) as $method) {
            $container->callMethod([$service, $method]);
        }
        foreach (self::getInjectProperties(get_class($service)) as $property => $type) {
            self::checkType($service, $property, $type, $container);
            $service->{$property} = $container->getByType($type);
        }
    }

Usage Example

Пример #1
0
 private function initialiseSchema()
 {
     $input = new ArrayInput(array('--force' => true));
     $output = new StringOutput();
     InjectExtension::callInjects($this->context, $this->schemaUpdateCommand);
     $this->schemaUpdateCommand->setHelperSet(new HelperSet(['em' => new EntityManagerHelper($this->em)]));
     $this->schemaUpdateCommand->run($input, $output);
     $this->messages[] = $output->getOutput();
 }
All Usage Examples Of Nette\DI\Extensions\InjectExtension::callInjects