Skip to content

[FrameworkBundle] Introduced new method for getting bundles config path #41566

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

Merged
merged 1 commit into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CHANGELOG
* Deprecate the `AdapterInterface` autowiring alias, use `CacheItemPoolInterface` instead
* Deprecate the public `profiler` service to private
* Deprecate `get()`, `has()`, `getDoctrine()`, and `dispatchMessage()` in `AbstractController`, use method/constructor injection instead
* Add `MicroKernelTrait::getBundlesPath` method to get bundles config path

5.3
---
Expand Down
12 changes: 10 additions & 2 deletions src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function getLogDir(): string
*/
public function registerBundles(): iterable
{
$contents = require $this->getProjectDir().'/config/bundles.php';
$contents = require $this->getBundlesPath();
foreach ($contents as $class => $envs) {
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
yield new $class();
Expand Down Expand Up @@ -124,7 +124,7 @@ public function registerContainerConfiguration(LoaderInterface $loader)
$kernelDefinition->addTag('routing.route_loader');

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

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

return $collection;
}

/**
* Gets the path to the bundles configuration file.
*/
private function getBundlesPath(): string
{
return $this->getProjectDir().'/config/bundles.php';
}
}