8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 47c90c6 + be4bbb6 commit 336de16Copy full SHA for 336de16
Kernel.php
@@ -82,7 +82,6 @@ public function __construct($environment, $debug)
82
$this->environment = $environment;
83
$this->debug = (bool) $debug;
84
$this->rootDir = $this->getRootDir();
85
- $this->projectDir = $this->getProjectDir();
86
$this->name = $this->getName();
87
88
if ($this->debug) {
@@ -604,7 +603,7 @@ protected function getKernelParameters()
604
603
return array_merge(
605
array(
606
'kernel.root_dir' => realpath($this->rootDir) ?: $this->rootDir,
607
- 'kernel.project_dir' => realpath($this->projectDir) ?: $this->projectDir,
+ 'kernel.project_dir' => realpath($this->getProjectDir()) ?: $this->getProjectDir(),
608
'kernel.environment' => $this->environment,
609
'kernel.debug' => $this->debug,
610
'kernel.name' => $this->name,
Tests/KernelTest.php
@@ -12,6 +12,7 @@
12
namespace Symfony\Component\HttpKernel\Tests;
13
14
use PHPUnit\Framework\TestCase;
15
+use Symfony\Component\Config\Loader\LoaderInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
18
use Symfony\Component\HttpKernel\Config\EnvParametersResource;
@@ -761,6 +762,15 @@ public function testSymfonyEnvironmentVariables()
761
762
unset($_SERVER['SYMFONY__FOO__BAR']);
763
}
764
765
+ public function testProjectDirExtension()
766
+ {
767
+ $kernel = new CustomProjectDirKernel('test', true);
768
+ $kernel->boot();
769
+
770
+ $this->assertSame('foo', $kernel->getProjectDir());
771
+ $this->assertSame('foo', $kernel->getContainer()->getParameter('kernel.project_dir'));
772
+ }
773
774
/**
775
* Returns a mock for the BundleInterface.
776
*
@@ -857,3 +867,34 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch =
857
867
{
858
868
859
869
870
871
+class CustomProjectDirKernel extends Kernel
872
+{
873
+ private $baseDir;
874
875
+ public function __construct()
876
877
+ parent::__construct('test', false);
878
879
+ $this->baseDir = 'foo';
880
881
882
+ public function registerBundles()
883
884
+ return array();
885
886
887
+ public function registerContainerConfiguration(LoaderInterface $loader)
888
889
890
891
+ public function getProjectDir()
892
893
+ return $this->baseDir;
894
895
896
+ public function getRootDir()
897
898
+ return __DIR__.'/Fixtures';
899
900
+}