Set up kernel file & bootstrap application if needed
This commit is contained in:
@@ -123,9 +123,11 @@ final class SymfonyExtension implements Extension
|
|||||||
$config['debug'],
|
$config['debug'],
|
||||||
));
|
));
|
||||||
$definition->addMethodCall('boot');
|
$definition->addMethodCall('boot');
|
||||||
|
$definition->setFile($this->getKernelFile($container->getParameter('paths.base'), $config['path']));
|
||||||
|
|
||||||
$container->setDefinition(self::KERNEL_ID, $definition);
|
$container->setDefinition(self::KERNEL_ID, $definition);
|
||||||
$container->setParameter(self::KERNEL_ID . '.path', $config['path']);
|
|
||||||
$container->setParameter(self::KERNEL_ID . '.bootstrap', $config['bootstrap']);
|
$this->requireKernelBootstrapFile($container->getParameter('paths.base'), $config['bootstrap']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -199,4 +201,54 @@ final class SymfonyExtension implements Extension
|
|||||||
new Reference(self::DRIVER_KERNEL_ID)
|
new Reference(self::DRIVER_KERNEL_ID)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $basePath
|
||||||
|
* @param string $kernelPath
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
private function getKernelFile($basePath, $kernelPath)
|
||||||
|
{
|
||||||
|
$possibleFiles = [
|
||||||
|
sprintf('%s/%s', $basePath, $kernelPath),
|
||||||
|
$kernelPath,
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($possibleFiles as $possibleFile) {
|
||||||
|
if (file_exists($possibleFile)) {
|
||||||
|
return $possibleFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $basePath
|
||||||
|
* @param string|null $bootstrapPath
|
||||||
|
*
|
||||||
|
* @throws \DomainException
|
||||||
|
*/
|
||||||
|
private function requireKernelBootstrapFile($basePath, $bootstrapPath)
|
||||||
|
{
|
||||||
|
if (null === $bootstrapPath) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$possiblePaths = [
|
||||||
|
sprintf('%s/%s', $basePath, $bootstrapPath),
|
||||||
|
$bootstrapPath,
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($possiblePaths as $possiblePath) {
|
||||||
|
if (file_exists($possiblePath)) {
|
||||||
|
require_once $possiblePath;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \DomainException('Could not load bootstrap file.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user