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_THREAD, '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;
}