File tree 3 files changed +34
-0
lines changed
src/Symfony/Component/HttpKernel
3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ CHANGELOG
11
11
* content of request parameter ` _password ` is now also hidden
12
12
in the request profiler raw content section
13
13
* Allowed adding attributes on controller arguments that will be passed to argument resolvers.
14
+ * kernels implementing the ` ExtensionInterface ` will now be auto-registered to the container
14
15
15
16
5.1.0
16
17
-----
Original file line number Diff line number Diff line change 23
23
use Symfony \Component \DependencyInjection \ContainerInterface ;
24
24
use Symfony \Component \DependencyInjection \Dumper \PhpDumper ;
25
25
use Symfony \Component \DependencyInjection \Dumper \Preloader ;
26
+ use Symfony \Component \DependencyInjection \Extension \ExtensionInterface ;
26
27
use Symfony \Component \DependencyInjection \Loader \ClosureLoader ;
27
28
use Symfony \Component \DependencyInjection \Loader \DirectoryLoader ;
28
29
use Symfony \Component \DependencyInjection \Loader \GlobFileLoader ;
@@ -688,6 +689,9 @@ protected function getContainerBuilder()
688
689
$ container = new ContainerBuilder ();
689
690
$ container ->getParameterBag ()->add ($ this ->getKernelParameters ());
690
691
692
+ if ($ this instanceof ExtensionInterface) {
693
+ $ container ->registerExtension ($ this );
694
+ }
691
695
if ($ this instanceof CompilerPassInterface) {
692
696
$ container ->addCompilerPass ($ this , PassConfig::TYPE_BEFORE_OPTIMIZATION , -10000 );
693
697
}
Original file line number Diff line number Diff line change 16
16
use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
17
17
use Symfony \Component \DependencyInjection \ContainerBuilder ;
18
18
use Symfony \Component \DependencyInjection \ContainerInterface ;
19
+ use Symfony \Component \DependencyInjection \Extension \ExtensionInterface ;
19
20
use Symfony \Component \Filesystem \Filesystem ;
20
21
use Symfony \Component \HttpFoundation \Request ;
21
22
use Symfony \Component \HttpFoundation \Response ;
@@ -475,6 +476,34 @@ public function testKernelReset()
475
476
$ this ->assertFileExists (\dirname ($ containerFile ).'.legacy ' );
476
477
}
477
478
479
+ public function testKernelExtension ()
480
+ {
481
+ $ kernel = new class () extends CustomProjectDirKernel implements ExtensionInterface {
482
+ public function load (array $ configs , ContainerBuilder $ container )
483
+ {
484
+ $ container ->setParameter ('test.extension-registered ' , true );
485
+ }
486
+
487
+ public function getNamespace ()
488
+ {
489
+ return '' ;
490
+ }
491
+
492
+ public function getXsdValidationBasePath ()
493
+ {
494
+ return false ;
495
+ }
496
+
497
+ public function getAlias ()
498
+ {
499
+ return 'test-extension ' ;
500
+ }
501
+ };
502
+ $ kernel ->boot ();
503
+
504
+ $ this ->assertTrue ($ kernel ->getContainer ()->getParameter ('test.extension-registered ' ));
505
+ }
506
+
478
507
public function testKernelPass ()
479
508
{
480
509
$ kernel = new PassKernel ();
You can’t perform that action at this time.
0 commit comments