-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Added a build method to the kernel to replace Bundle::build() #20107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -466,6 +466,17 @@ protected function initializeBundles() | |
} | ||
} | ||
|
||
/** | ||
* The extension point similar to the Bundle::build() method. | ||
* | ||
* Use this method to register compiler passes and manipulate the container during the building process. | ||
* | ||
* @param ContainerBuilder $container | ||
*/ | ||
protected function build(ContainerBuilder $container) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like the name of this method. According to the Symfony naming conventions I think this should be called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So isnt If you go bundles, you probably (should) go extensions anyway. If you want a more simple bundle i'd prefer the approach from #19596. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @javiereguiluz buildContainer is already taken |
||
{ | ||
} | ||
|
||
/** | ||
* Gets the container class. | ||
* | ||
|
@@ -625,10 +636,13 @@ protected function prepareContainer(ContainerBuilder $container) | |
$container->addObjectResource($bundle); | ||
} | ||
} | ||
|
||
foreach ($this->bundles as $bundle) { | ||
$bundle->build($container); | ||
} | ||
|
||
$this->build($container); | ||
|
||
// ensure these extensions are implicitly loaded | ||
$container->getCompilerPassConfig()->setMergePass(new MergeExtensionConfigurationPass($extensions)); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\HttpKernel\Tests\Fixtures; | ||
|
||
use Symfony\Component\Config\Loader\LoaderInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpKernel\Kernel; | ||
|
||
class KernelWithoutBundles extends Kernel | ||
{ | ||
public function registerBundles() | ||
{ | ||
return array(); | ||
} | ||
|
||
public function registerContainerConfiguration(LoaderInterface $loader) | ||
{ | ||
} | ||
|
||
protected function build(ContainerBuilder $container) | ||
{ | ||
$container->setParameter('test_executed', true); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically, you can already achieve this by overriding
Kernel::buildContainer
, as long as you take care to start by calling the parent method.