Skip to content

Commit

Permalink
Use KERNEL_DIR for BC only
Browse files Browse the repository at this point in the history
  • Loading branch information
covex-nn authored and dbu committed Jun 29, 2018
1 parent 13dbdbc commit 63f94e1
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions bootstrap/kernel_bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,27 @@

$xml = new \SimpleXMLElement(file_get_contents($phpUnitFile));

$envDir = $xml->xpath("//php/server[@name='KERNEL_DIR']");
if (!count($envDir)) {
throw new \Exception(
'Kernel path must be set via <server name"KERNEL_DIR" value="..."/>'
);
}
$envClass = $xml->xpath("//php/env[@name='KERNEL_CLASS']");

$kernelClass = count($envClass) ? (string) $envClass[0]['value'] : 'AppKernel';
$kernelNs = explode('\\', $kernelClass);
$kernelFile = $rootDir.'/'.$envDir[0]['value'].'/'.array_pop($kernelNs).'.php';

if (!file_exists($kernelFile)) {
throw new \Exception(sprintf(
'Cannot find kernel file "%s"',
$kernelFile
));
if (count($envClass)) {
$kernelClass = (string) $envClass[0]['value'];
} else {
$envDir = $xml->xpath("//php/server[@name='KERNEL_DIR']");
if (!count($envDir)) {
throw new \Exception(
'KERNEL_CLASS must be set via <env name"KERNEL_CLASS" value="..."/>'
);
}
$kernelClass = 'AppKernel';
$kernelFile = $rootDir.'/'.$envDir[0]['value'].'/'.$kernelClass.'.php';

if (!file_exists($kernelFile)) {
throw new \Exception(sprintf(
'Cannot find kernel file "%s"',
$kernelFile
));
}

require_once $kernelFile;
}

require_once $kernelFile;

return new $kernelClass($env, true);

0 comments on commit 63f94e1

Please sign in to comment.