8000 feature #41566 [FrameworkBundle] Introduced new method for getting bu… · symfony/symfony@7c531f5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7c531f5

Browse files
committed
feature #41566 [FrameworkBundle] Introduced new method for getting bundles config path (a-menshchikov)
This PR was merged into the 5.4 branch. Discussion ---------- [FrameworkBundle] Introduced new method for getting bundles config path | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | | License | MIT | Doc PR | symfony/symfony-docs#15423 At the moment bundles path duplicated in MicroKernelTrait: in `registerBundles` and `registerContainerConfiguration` methods. This leads to need to override the both methods if bundles config stored by custom path (e.g. when multiple kernels used). The new method allows override the only itself when custom path is used. Commits ------- b81b489 Introduced new method for getting bundles config path
2 parents 8042736 + b81b489 commit 7c531f5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CHANGELOG
88
* Deprecate the `AdapterInterface` autowiring alias, use `CacheItemPoolInterface` instead
99
* Deprecate the public `profiler` service to private
1010
* Deprecate `get()`, `has()`, `getDoctrine()`, and `dispatchMessage()` in `AbstractController`, use method/constructor injection instead
11+
* Add `MicroKernelTrait::getBundlesPath` method to get bundles config path
1112

1213
5.3
1314
---

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function getLogDir(): string
8888
*/
8989
public function registerBundles(): iterable
9090
{
91-
$contents = require $this->getProjectDir().'/config/bundles.php';
91+
$contents = require $this->getBundlesPath();
9292
foreach ($contents as $class => $envs) {
9393
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
9494
yield new $class();
@@ -124,7 +124,7 @@ public function registerContainerConfiguration(LoaderInterface $loader)
124124
$kernelDefinition->addTag('routing.route_loader');
125125

126126
$container->addObjectResource($this);
127-
$container->fileExists($this->getProjectDir().'/config/bundles.php');
127+
$container->fileExists($this->getBundlesPath());
128128

129129
try {
130130
$configureContainer = new \ReflectionMethod($this, 'configureContainer');
@@ -203,4 +203,12 @@ public function loadRoutes(LoaderInterface $loader): RouteCollection
203203

204204
return $collection;
205205
}
206+
207+
/**
208+
* Gets the path to the bundles configuration file.
209+
*/
210+
private function getBundlesPath(): string
211+
{
212+
return $this->getProjectDir().'/config/bundles.php';
213+
}
206214
}

0 commit comments

Comments
 (0)
0