Пример #1
0
 /**
  * @param string $path
  * @return ClientInterface
  */
 public function boot($path)
 {
     $core = (require realpath($path) . '/bootstrap/Console/Client/bootstrap.php');
     $controller = (new ReflectionClass(StringSupport::parametrize($this->controllerClass, $this->params)))->newInstanceArgs(array_merge($this->controllerParams));
     $controller->setCore($core);
     $core->config($controller->internalConfig($core));
     $controller->internalBoot($core);
     $core->boot();
     $controller->internalConstruct($core);
     return $controller;
 }
Пример #2
0
 /**
  * @param string $path
  * @return RuntimeContainerInterface
  */
 public function boot($path)
 {
     $datapath = realpath($path);
     $core = (require $datapath . '/bootstrap/Console/Server/bootstrap.php');
     $controller = (new ReflectionClass(StringSupport::parametrize($this->controllerClass, $this->params)))->newInstanceArgs(array_merge($this->controllerParams));
     $controller->setCore($core);
     $core->config($controller->internalConfig($core));
     $controller->internalBoot($core);
     $core->boot();
     $controller->getLoop()->setFlowController($this->runtimeController);
     $controller->internalConstruct($core);
     return $controller;
 }
Пример #3
0
 /**
  * @param string $name
  * @param ProtocolInterface $protocol
  * @return bool
  */
 public function __invoke($name, ProtocolInterface $protocol)
 {
     return StringSupport::match($this->name, $name);
 }
Пример #4
0
 /**
  * @param string $path
  * @param string $level
  * @return string
  */
 private function filePath($path, $level)
 {
     return StringSupport::parametrize($path, ['level' => $level, 'date' => date('Y-m-d'), 'time' => date('H:i:s')]);
 }
Пример #5
0
 /**
  * @param ConfigInterface $config
  */
 private function configure(ConfigInterface $config)
 {
     if ($config->exists('imports')) {
         $resources = (array) $config->get('imports');
     } else {
         $resources = [];
     }
     foreach ($resources as $resource) {
         $handler = isset($resource['mode']) ? $this->getOverwriteHandler($resource['mode']) : null;
         $path = StringSupport::parametrize($resource['resource'], $this->getDefaultVariables());
         $current = $this->createConfig($path);
         $this->configure($current);
         $config->merge($current->getAll(), $handler);
     }
 }
Пример #6
0
 /**
  * @param string $path
  * @return RuntimeContainerInterface
  * @throws Exception
  */
 public function boot($path)
 {
     $controllerClass = '';
     $controllerClassFound = false;
     foreach ($this->controllerPatterns as $controllerClass) {
         $controllerClass = StringSupport::parametrize($controllerClass, $this->params);
         if (class_exists($controllerClass)) {
             $controllerClassFound = true;
             break;
         }
     }
     if (!$controllerClassFound) {
         throw new InstantiationException('Runtime class not found');
     }
     $controller = (new ReflectionClass($controllerClass))->newInstanceArgs($this->controllerParams);
     $params = array_merge(['type' => $type = Runtime::UNIT_PROCESS, 'datapath' => realpath($path)], $this->params);
     $bootstrapFile = '';
     $bootstrapFileFound = false;
     foreach ($this->bootstrapPatterns as $bootstrapFile) {
         $bootstrapFile = StringSupport::parametrize($bootstrapFile, $params);
         if (file_exists($bootstrapFile)) {
             $bootstrapFileFound = true;
             break;
         }
     }
     if (!$bootstrapFileFound) {
         throw new InstantiationException('Bootstrap file not found');
     }
     $core = (require $bootstrapFile);
     $controller->setCore($core);
     $core->config($controller->internalConfig($core));
     $controller->internalBoot($core);
     $core->boot();
     $controller->getLoop()->setFlowController($this->runtimeController);
     $controller->internalConstruct($core);
     return $controller;
 }
Пример #7
0
 /**
  * @param string $exception
  * @param ProtocolInterface $protocol
  * @return bool
  */
 public function __invoke($exception, ProtocolInterface $protocol)
 {
     return StringSupport::match($this->exception, $protocol->getException());
 }
Пример #8
0
 /**
  * @override
  * @inheritDoc
  */
 public function filterConnected($pattern)
 {
     return StringSupport::find($pattern, $this->getConnected());
 }