Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitc65e787

Browse files
committed
Fix kernel.project_dir extensibility
1 parent1bbc35a commitc65e787

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

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

Lines 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
returnarray_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‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespaceSymfony\Component\HttpKernel\Tests;
1313

1414
usePHPUnit\Framework\TestCase;
15+
useSymfony\Component\Config\Loader\LoaderInterface;
1516
useSymfony\Component\DependencyInjection\ContainerBuilder;
1617
useSymfony\Component\HttpKernel\Bundle\BundleInterface;
1718
useSymfony\Component\HttpKernel\Config\EnvParametersResource;
@@ -761,6 +762,15 @@ public function testSymfonyEnvironmentVariables()
761762
unset($_SERVER['SYMFONY__FOO__BAR']);
762763
}
763764

765+
publicfunctiontestProjectDirExtension()
766+
{
767+
$kernel =newCustomProjectDirKernel('test',true);
768+
$kernel->boot();
769+
770+
$this->assertSame('foo',$kernel->getProjectDir());
771+
$this->assertSame('foo',$kernel->getContainer()->getParameter('kernel.project_dir'));
772+
}
773+
764774
/**
765775
* Returns a mock for the BundleInterface.
766776
*
@@ -857,3 +867,34 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch =
857867
{
858868
}
859869
}
870+
871+
class CustomProjectDirKernelextends Kernel
872+
{
873+
private$baseDir;
874+
875+
publicfunction__construct()
876+
{
877+
parent::__construct('test',false);
878+
879+
$this->baseDir ='foo';
880+
}
881+
882+
publicfunctionregisterBundles()
883+
{
884+
returnarray();
885+
}
886+
887+
publicfunctionregisterContainerConfiguration(LoaderInterface$loader)
888+
{
889+
}
890+
891+
publicfunctiongetProjectDir()
892+
{
893+
return$this->baseDir;
894+
}
895+
896+
publicfunctiongetRootDir()
897+
{
898+
return__DIR__.'/Fixtures';
899+
}
900+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp