예제 #1
0
 /**
  * {@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();
 }
예제 #2
0
 /**
  *
  * @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'));
 }
예제 #3
0
 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);
 }
예제 #4
0
 /**
  * @return Config
  */
 public function getConfig()
 {
     return $this->dependencyInjection->get('config');
 }
예제 #5
0
 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);
 }
예제 #6
0
파일: Root.php 프로젝트: itephp/framework
 /**
  *
  * @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'));
     }
 }