Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ce63ec3

Browse files
[FrameworkBundle] Added flex-based default implementation for MicroKernelTrait::registerBundles()
1 parent 24ed8e1 commit ce63ec3

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CHANGELOG
77
* Marked `MicroKernelTrait::configureRoutes()` as `@internal` and `@final`.
88
* Deprecated not overriding `MicroKernelTrait::configureRouting()`.
99
* Added a new `mailer.message_bus` option to configure or disable the message bus to use to send mails.
10+
* Added flex-based default implementation for `MicroKernelTrait::registerBundles()`
1011

1112
5.0.0
1213
-----

src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Kernel;
1313

1414
use Symfony\Component\Config\Loader\LoaderInterface;
15+
use Symfony\Component\Config\Resource\FileResource;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1718
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
@@ -72,6 +73,19 @@ protected function configureRouting(RoutingConfigurator $routes): void
7273
*/
7374
abstract protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader);
7475

76+
/**
77+
* {@inheritdoc}
78+
*/
79+
public function registerBundles(): iterable
80+
{
81+
$contents = require $this->getProjectDir().'/config/bundles.php';
82+
foreach ($contents as $class => $envs) {
83+
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
84+
yield new $class();
85+
}
86+
}
87+
}
88+
7589
/**
7690
* {@inheritdoc}
7791
*/
@@ -99,6 +113,10 @@ public function registerContainerConfiguration(LoaderInterface $loader)
99113
$kernelDefinition->addTag('kernel.event_subscriber');
100114
}
101115

116+
$container->fileExists($this->getProjectDir().'/config/bundles.php');
117+
$container->setParameter('container.dumper.inline_class_loader', \PHP_VERSION_ID < 70400 || !ini_get('opcache.preload'));
118+
$container->setParameter('container.dumper.inline_factories', true);
119+
102120
$this->configureContainer($container, $loader);
103121

104122
$container->addObjectResource($this);

0 commit comments

Comments
 (0)