Skip to content

Commit adb1a40

Browse files
committed
Merge branch '5.4' into 6.3
* 5.4: Reword the contents about bundles' logical paths
2 parents e36b44b + 7829a0e commit adb1a40

File tree

3 files changed

+16
-30
lines changed

3 files changed

+16
-30
lines changed

bundles/best_practices.rst

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -531,16 +531,12 @@ Resources
531531
---------
532532

533533
If the bundle references any resources (config files, translation files, etc.),
534-
don't use physical paths (e.g. ``__DIR__/config/services.xml``) but logical
535-
paths (e.g. ``@AcmeBlogBundle/config/services.xml``).
534+
you can use physical paths (e.g. ``__DIR__/config/services.xml``).
536535

537-
The logical paths are required because of the bundle overriding mechanism that
538-
lets you override any resource/file of any bundle. See :ref:`http-kernel-resource-locator`
539-
for more details about transforming physical paths into logical paths.
540-
541-
Beware that templates use a simplified version of the logical path shown above.
542-
For example, an ``index.html.twig`` template located in the ``templates/Default/``
543-
directory of the AcmeBlogBundle, is referenced as ``@AcmeBlog/Default/index.html.twig``.
536+
In the past, we recommended to only use logical paths (e.g.
537+
``@AcmeBlogBundle/config/services.xml``) and resolve them with the
538+
:ref:`resource locator <http-kernel-resource-locator>` provided by the Symfony
539+
kernel, but this is no longer a recommended practice.
544540

545541
Learn more
546542
----------

bundles/override.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ When using a third-party bundle, you might want to customize or override some of
55
its features. This document describes ways of overriding the most common
66
features of a bundle.
77

8-
.. tip::
9-
10-
The bundle overriding mechanism means that you cannot use physical paths to
11-
refer to bundle's resources (e.g. ``__DIR__/config/services.xml``). Always
12-
use logical paths in your bundles (e.g. ``@FooBundle/config/services.xml``)
13-
and call the :ref:`locateResource() method <http-kernel-resource-locator>`
14-
to turn them into physical paths when needed.
15-
168
.. _override-templates:
179

1810
Templates

components/http_kernel.rst

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -727,19 +727,17 @@ Locating Resources
727727
------------------
728728

729729
The HttpKernel component is responsible of the bundle mechanism used in Symfony
730-
applications. The key feature of the bundles is that they allow to override any
731-
resource used by the application (config files, templates, controllers,
732-
translation files, etc.)
733-
734-
This overriding mechanism works because resources are referenced not by their
735-
physical path but by their logical path. For example, the ``services.xml`` file
736-
stored in the ``Resources/config/`` directory of a bundle called FooBundle is
737-
referenced as ``@FooBundle/Resources/config/services.xml``. This logical path
738-
will work when the application overrides that file and even if you change the
739-
directory of FooBundle.
740-
741-
The HttpKernel component provides a method called :method:`Symfony\\Component\\HttpKernel\\Kernel::locateResource`
742-
which can be used to transform logical paths into physical paths::
730+
applications. One of the key features of the bundles is that you can use logic
731+
paths instead of physical paths to refer to any of their resources (config files,
732+
templates, controllers, translation files, etc.)
733+
734+
This allows to import resources even if you don't know where in the filesystem a
735+
bundle will be installed. For example, the ``services.xml`` file stored in the
736+
``Resources/config/`` directory of a bundle called FooBundle can be referenced as
737+
``@FooBundle/Resources/config/services.xml`` instead of ``__DIR__/Resources/config/services.xml``.
738+
739+
This is possible thanks to the :method:`Symfony\\Component\\HttpKernel\\Kernel::locateResource`
740+
method provided by the kernel, which transforms logical paths into physical paths::
743741

744742
$path = $kernel->locateResource('@FooBundle/Resources/config/services.xml');
745743

0 commit comments

Comments
 (0)