parametrize() public static method

Parametrize string using array of params.
public static parametrize ( string $str, string[] $params ) : string
$str string
$params string[]
return string
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 3
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')]);
 }
Exemplo n.º 4
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);
     }
 }
Exemplo n.º 5
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;
 }