Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 234361e

Browse filesBrowse files
committed
Fix kernel.project_dir extensibility
1 parent 1bbc35a commit 234361e
Copy full SHA for 234361e

File tree

2 files changed

+44
-2
lines changed
Filter options

2 files changed

+44
-2
lines changed

‎src/Symfony/Component/HttpKernel/Kernel.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Kernel.php
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ public function __construct($environment, $debug)
8282
$this->environment = $environment;
8383
$this->debug = (bool) $debug;
8484
$this->rootDir = $this->getRootDir();
85-
$this->projectDir = $this->getProjectDir();
8685
$this->name = $this->getName();
8786

8887
if ($this->debug) {
@@ -604,7 +603,7 @@ protected function getKernelParameters()
604603
return array_merge(
605604
array(
606605
'kernel.root_dir' => realpath($this->rootDir) ?: $this->rootDir,
607-
'kernel.project_dir' => realpath($this->projectDir) ?: $this->projectDir,
606+
'kernel.project_dir' => realpath($this->getProjectDir()) ?: $this->getProjectDir(),
608607
'kernel.environment' => $this->environment,
609608
'kernel.debug' => $this->debug,
610609
'kernel.name' => $this->name,

‎src/Symfony/Component/HttpKernel/Tests/KernelTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/KernelTest.php
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
namespace Symfony\Component\HttpKernel\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Config\Loader\LoaderInterface;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
17+
use Symfony\Component\Filesystem\Filesystem;
1618
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
1719
use Symfony\Component\HttpKernel\Config\EnvParametersResource;
1820
use Symfony\Component\HttpKernel\Kernel;
@@ -761,6 +763,15 @@ public function testSymfonyEnvironmentVariables()
761763
unset($_SERVER['SYMFONY__FOO__BAR']);
762764
}
763765

766+
public function testProjectDirExtension()
767+
{
768+
$kernel = new CustomProjectDirKernel('test', true);
769+
$kernel->boot();
770+
771+
$this->assertSame('foo', $kernel->getProjectDir());
772+
$this->assertSame('foo', $kernel->getContainer()->getParameter('kernel.project_dir'));
773+
}
774+
764775
/**
765776
* Returns a mock for the BundleInterface.
766777
*
@@ -857,3 +868,35 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch =
857868
{
858869
}
859870
}
871+
872+
class CustomProjectDirKernel extends Kernel
873+
{
874+
private $baseDir;
875+
876+
public function __construct()
877+
{
878+
parent::__construct('test', false);
879+
880+
$this->baseDir = 'foo';
881+
}
882+
883+
884+
public function registerBundles()
885+
{
886+
return array();
887+
}
888+
889+
public function registerContainerConfiguration(LoaderInterface $loader)
890+
{
891+
}
892+
893+
public function getProjectDir()
894+
{
895+
return $this->baseDir;
896+
}
897+
898+
public function getRootDir()
899+
{
900+
return __DIR__.'/Fixtures';
901+
}
902+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.