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

Skip to content

Commit 21b810e

Browse files
[FrameworkBundle] Added flex-compatible default implementations for MicroKernelTrait::registerBundles() and getProjectDir()
1 parent 65a9888 commit 21b810e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-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-compatible default implementations for `MicroKernelTrait::registerBundles()` and `getProjectDir()`
1011

1112
5.0.0
1213
-----

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,27 @@ protected function configureRouting(RoutingConfigurator $routes): void
7272
*/
7373
abstract protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader);
7474

75+
/**
76+
* {@inheritdoc}
77+
*/
78+
public function getProjectDir(): string
79+
{
80+
return \dirname((new \ReflectionObject($this))->getFileName(), 2);
81+
}
82+
83+
/**
84+
* {@inheritdoc}
85+
*/
86+
public function registerBundles(): iterable
87+
{
88+
$contents = require $this->getProjectDir().'/config/bundles.php';
89+
foreach ($contents as $class => $envs) {
90+
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
91+
yield new $class();
92+
}
93+
}
94+
}
95+
7596
/**
7697
* {@inheritdoc}
7798
*/
@@ -99,6 +120,10 @@ public function registerContainerConfiguration(LoaderInterface $loader)
99120
$kernelDefinition->addTag('kernel.event_subscriber');
100121
}
101122

123+
$container->fileExists($this->getProjectDir().'/config/bundles.php');
124+
$container->setParameter('container.dumper.inline_class_loader', \PHP_VERSION_ID < 70400);
125+
$container->setParameter('container.dumper.inline_factories', true);
126+
102127
$this->configureContainer($container, $loader);
103128

104129
$container->addObjectResource($this);

0 commit comments

Comments
 (0)