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

Commit6973a1a

Browse files
[HttpKernel][DI] Enable Kernel to implement CompilerPassInterface
1 parentaad62c4 commit6973a1a

File tree

6 files changed

+33
-1
lines changed

6 files changed

+33
-1
lines changed

‎UPGRADE-4.0.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ DependencyInjection
184184

185185
* Top-level anonymous services in XML are no longer supported.
186186

187+
* The `ExtensionCompilerPass` has been moved to before-optimization passes with priority -1000.
188+
187189
EventDispatcher
188190
---------------
189191

‎src/Symfony/Component/DependencyInjection/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
3.4.0
55
-----
66

7+
* moved the`ExtensionCompilerPass` to before-optimization passes with priority -1000
78
* deprecated "public-by-default" definitions and aliases, the new default will be "private" in 4.0
89
* added`EnvVarProcessorInterface` and corresponding "container.env_var_processor" tag for processing env vars
910
* added support for ignore-on-uninitialized references

‎src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ public function __construct()
4545
newResolveInstanceofConditionalsPass(),
4646
newRegisterEnvVarProcessorsPass(),
4747
),
48+
-1000 =>array(newExtensionCompilerPass()),
4849
);
4950

5051
$this->optimizationPasses =array(array(
51-
newExtensionCompilerPass(),
5252
newResolveChildDefinitionsPass(),
5353
newServiceLocatorTagPass(),
5454
newDecoratorServicePass(),

‎src/Symfony/Component/HttpKernel/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
3.4.0
55
-----
66

7+
* made kernels implementing`CompilerPassInterface` able to process the container
78
* deprecated bundle inheritance
89
* added`RebootableInterface` and implemented it in`Kernel`
910
* deprecated commands auto registration

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
useSymfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator;
1515
useSymfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
16+
useSymfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17+
useSymfony\Component\DependencyInjection\Compiler\PassConfig;
1618
useSymfony\Component\DependencyInjection\ContainerInterface;
1719
useSymfony\Component\DependencyInjection\ContainerBuilder;
1820
useSymfony\Component\DependencyInjection\Dumper\PhpDumper;
@@ -767,6 +769,9 @@ protected function getContainerBuilder()
767769
$container =newContainerBuilder();
768770
$container->getParameterBag()->add($this->getKernelParameters());
769771

772+
if ($thisinstanceof CompilerPassInterface) {
773+
$container->addCompilerPass($this, PassConfig::TYPE_BEFORE_OPTIMIZATION, -10000);
774+
}
770775
if (class_exists('ProxyManager\Configuration') &&class_exists('Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator')) {
771776
$container->setProxyInstantiator(newRuntimeInstantiator());
772777
}

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
usePHPUnit\Framework\TestCase;
1515
useSymfony\Component\Config\Loader\LoaderInterface;
16+
useSymfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1617
useSymfony\Component\DependencyInjection\ContainerBuilder;
1718
useSymfony\Component\Filesystem\Filesystem;
1819
useSymfony\Component\HttpKernel\Bundle\BundleInterface;
@@ -831,6 +832,14 @@ public function testKernelReset()
831832
$this->assertFileNotExists($containerFile);
832833
}
833834

835+
publicfunctiontestKernelPass()
836+
{
837+
$kernel =newPassKernel();
838+
$kernel->boot();
839+
840+
$this->assertTrue($kernel->getContainer()->getParameter('test.processed'));
841+
}
842+
834843
/**
835844
* Returns a mock for the BundleInterface.
836845
*
@@ -967,3 +976,17 @@ protected function build(ContainerBuilder $container)
967976
}
968977
}
969978
}
979+
980+
class PassKernelextends CustomProjectDirKernelimplements CompilerPassInterface
981+
{
982+
publicfunction__construct(\Closure$buildContainer =null)
983+
{
984+
parent::__construct();
985+
Kernel::__construct('pass',true);
986+
}
987+
988+
publicfunctionprocess(ContainerBuilder$container)
989+
{
990+
$container->setParameter('test.processed',true);
991+
}
992+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp