/** * {@inheritDoc} */ public function execute() { /** * @var CommandInterface $command */ $command = $this->dependencyInjection->get('command.' . $this->className); $commandExecutor = new CommandExecutor($command); $commandExecutor->setOutputStream(new OutputStreamConsole()); $commandExecutor->setArguments($this->arguments); $commandExecutor->run(); }
/** * * @param string $url * @return Presenter */ private function getPresenter($url) { /** * @var Config $config */ $config = $this->dependencyInjection->get('config'); foreach ($config->getNodes('error') as $error) { if (!preg_match('/^' . $error->getAttribute('pattern') . '$/', $url)) { continue; } $presenterName = $error->getAttribute('presenter'); /** * @var Presenter $presenterObject */ $presenterObject = $this->dependencyInjection->get('presenter.' . $presenterName); return $presenterObject; } return new HTMLPresenter($this->dependencyInjection->get('environment')); }
private function createHandler($url) { $environment = new Environment(true, true, 'test', __DIR__); $_SERVER = []; $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; $session = new Session($environment); $request = new HTTPRequest($url, $session); $dependencyInjection = new DependencyInjection(); $dependencyInjection->addInstance('environment', $environment); $dependencyInjection->addInstance('config', $this->createConfigContainer()); $dependencyInjection->addInstance('eventManager', new EventManager()); $dependencyInjection->addInstance('presenter.html', new HTML($environment)); $dependencyInjection->addInstance('presenter.json', new JSON($environment)); return new HTTPErrorHandler($dependencyInjection, $request); }
/** * @return Config */ public function getConfig() { return $this->dependencyInjection->get('config'); }
public function testGetInvalidTypeException() { $metadataClass = new MetadataClass('standalone', 'Asset\\StandaloneClass'); $metadataMethod = new MetadataMethod('__construct'); $metadataMethod->addArgument('unknown', 'param1'); $metadataMethod->addArgument(MetadataMethod::PRIMITIVE_TYPE, 'param2'); $metadataClass->registerInvoke($metadataMethod); $metadataMethod = new MetadataMethod('setParam3'); $metadataMethod->addArgument(MetadataMethod::PRIMITIVE_TYPE, 'data'); $metadataClass->registerInvoke($metadataMethod); $di = new DependencyInjection(); $di->register($metadataClass); $exception = null; try { $di->get('standalone'); } catch (\Exception $e) { $exception = $e; } $this->assertInstanceOf(InvalidTypeException::class, $exception); }
/** * * @param Config $eventNode * @param DependencyInjection $dependencyInjection */ private function eventManagerBind(Config $eventNode, DependencyInjection $dependencyInjection) { $eventManager = $this->container->getEventManager(); foreach ($eventNode->getNodes('bind') as $bindNode) { /** * @var Config $bindNode */ $eventManager->register($bindNode->getAttribute('name'), $dependencyInjection->get($eventNode->getAttribute('class')), $bindNode->getAttribute('method')); } }