Skip to content

Update override article #2601

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 3 commits into from
May 16, 2013
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
9 changes: 3 additions & 6 deletions cookbook/bundles/inheritance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,9 @@ The same goes for routing files, validation configuration and other resources.

.. caution::

Translation files do not work in the same way as described above. All
translation files are accumulated into a set of "pools" (one for each)
domain. Symfony loads translation files from bundles first (in the order
that the bundles are initialized) and then from your ``app/Resources``
directory. If the same translation is specified in two resources, the
translation from the resource that's loaded last will win.
Translation files do not work in the same way as described above. Read
:ref:`override-translations` if you want to learn how to override
translations.

.. _`FOSUserBundle`: https://github.com/friendsofsymfony/fosuserbundle

25 changes: 23 additions & 2 deletions cookbook/bundles/override.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Templates
---------

For information on overriding templates, see

* :ref:`overriding-bundle-templates`.
* :doc:`/cookbook/bundles/inheritance`

Expand All @@ -31,6 +32,7 @@ Controllers
Assuming the third-party bundle involved uses non-service controllers (which
is almost always the case), you can easily override controllers via bundle
inheritance. For more information, see :doc:`/cookbook/bundles/inheritance`.
If the controller is a service, see the next section on how to override it.

Services & Configuration
------------------------
Expand Down Expand Up @@ -94,7 +96,11 @@ like adding a method call - you can only use the compiler pass method.
Entities & Entity mapping
-------------------------

In progress...
Due to the way Doctrine works, it is not possible to override entity mapping
of a bundle. However, if a bundle provides a mapped superclass (such as the
``User`` entity in the FOSUserBundle) one can override attributes and
associations. Learn more about this feature and its limitations in
`the Doctrine documentation`_.

Forms
-----
Expand All @@ -116,7 +122,22 @@ Validation metadata

In progress...

.. _override-translations:

Translations
------------

In progress...
Translations are not related to bundles, but to domains. That means that you
can override the translations from any translation file, as long as it is in
:ref:`the correct domain <translation-domains>`.

.. caution::

The last translation file always wins. That mean that you need to make
sure to load the class which overrides the translation of another bundle
before that bundle in the ``AppKernel``.

The file that always wins is the one that is placed in
``app/Resources/translations``, as those files are always loaded as last.

.. _`the Doctrine documentation`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/inheritance-mapping.html#overrides