diff --git a/src/Symfony/Component/HttpKernel/Bundle/AbstractBundle.php b/src/Symfony/Component/HttpKernel/Bundle/AbstractBundle.php index 3e6029f8c2510..244f3ec32b0b2 100644 --- a/src/Symfony/Component/HttpKernel/Bundle/AbstractBundle.php +++ b/src/Symfony/Component/HttpKernel/Bundle/AbstractBundle.php @@ -47,4 +47,18 @@ public function getContainerExtension(): ?ExtensionInterface return $this->extension ??= new BundleExtension($this, $this->extensionAlias); } + + /** + * {@inheritdoc} + */ + public function getPath(): string + { + if (null === $this->path) { + $reflected = new \ReflectionObject($this); + // assume the modern directory structure by default + $this->path = \dirname($reflected->getFileName(), 2); + } + + return $this->path; + } } diff --git a/src/Symfony/Component/HttpKernel/CHANGELOG.md b/src/Symfony/Component/HttpKernel/CHANGELOG.md index 6c40b7da3a66a..bb26bd4145017 100644 --- a/src/Symfony/Component/HttpKernel/CHANGELOG.md +++ b/src/Symfony/Component/HttpKernel/CHANGELOG.md @@ -10,6 +10,7 @@ CHANGELOG * Add `Profiler::isEnabled()` so collaborating collector services may elect to omit themselves * Add the `UidValueResolver` argument value resolver * Add `AbstractBundle` class for DI configuration/definition on a single file + * Update the path of a bundle placed in the `src/` directory to the parent directory when `AbstractBundle` is used 6.0 ---