Skip to content

Commit a54a981

Browse files
committed
Extend AbstractBundle instead of Bundle
1 parent e7d5408 commit a54a981

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

bundles/best_practices.rst

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,22 @@ The following is the recommended directory structure of an AcmeBlogBundle:
7878
├── LICENSE
7979
└── README.md
8080
81-
This directory structure requires to configure the bundle path to its root
82-
directory as follows::
81+
.. note::
82+
83+
This directory structure is used by default when your bundle class extends
84+
the recommended :class:`Symfony\\Component\\HttpKernel\\Bundle\\AbstractBundle`.
85+
If your bundle extends the :class:`Symfony\\Component\\HttpKernel\\Bundle\\Bundle`
86+
class, you have to override the ``getPath()`` method as follows::
8387

84-
class AcmeBlogBundle extends Bundle
85-
{
86-
public function getPath(): string
88+
use Symfony\Component\HttpKernel\Bundle\Bundle;
89+
90+
class AcmeBlogBundle extends Bundle
8791
{
88-
return \dirname(__DIR__);
92+
public function getPath(): string
93+
{
94+
return \dirname(__DIR__);
95+
}
8996
}
90-
}
9197

9298
**The following files are mandatory**, because they ensure a structure convention
9399
that automated tools can rely on:

service_container/compiler_passes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ method in the extension)::
7575

7676
use App\DependencyInjection\Compiler\CustomPass;
7777
use Symfony\Component\DependencyInjection\ContainerBuilder;
78-
use Symfony\Component\HttpKernel\Bundle\Bundle;
78+
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
7979

80-
class MyBundle extends Bundle
80+
class MyBundle extends AbstractBundle
8181
{
8282
public function build(ContainerBuilder $container): void
8383
{

0 commit comments

Comments
 (0)