Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f144c85

Browse filesBrowse files
committed
minor #7090 Remove suggestion to change the .class parameters (mpdude)
This PR was submitted for the 3.0 branch but it was merged into the 2.7 branch instead (closes #7090). Discussion ---------- Remove suggestion to change the `.class` parameters To my knowledge, this practice has been discouraged and the corresponding configuration hooks have been dropped in Symfony 3.0. Commits ------- 4d59cad Remove suggestion to change the parameters
2 parents fcb1fdf + 4d59cad commit f144c85
Copy full SHA for f144c85

File tree

Expand file treeCollapse file tree

1 file changed

+5
-39
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-39
lines changed

‎bundles/override.rst

Copy file name to clipboardExpand all lines: bundles/override.rst
+5-39Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -37,39 +37,10 @@ If the controller is a service, see the next section on how to override it.
3737
Services & Configuration
3838
------------------------
3939

40-
In order to override/extend a service, there are two options. First, you can
41-
set the parameter holding the service's class name to your own class by setting
42-
it in ``app/config/config.yml``. This of course is only possible if the class name is
43-
defined as a parameter in the service config of the bundle containing the
44-
service. For example, to override the class used for Symfony's ``translator``
45-
service, you would override the ``translator.class`` parameter. Knowing exactly
46-
which parameter to override may take some research. For the translator, the
47-
parameter is defined and used in the ``Resources/config/translation.xml`` file
48-
in the core FrameworkBundle:
49-
50-
.. configuration-block::
51-
52-
.. code-block:: yaml
53-
54-
# app/config/config.yml
55-
parameters:
56-
translator.class: Acme\HelloBundle\Translation\Translator
57-
58-
.. code-block:: xml
59-
60-
<!-- app/config/config.xml -->
61-
<parameters>
62-
<parameter key="translator.class">Acme\HelloBundle\Translation\Translator</parameter>
63-
</parameters>
64-
65-
.. code-block:: php
66-
67-
// app/config/config.php
68-
$container->setParameter('translator.class', 'Acme\HelloBundle\Translation\Translator');
69-
70-
Secondly, if the class is not available as a parameter, you want to make sure the
71-
class is always overridden when your bundle is used or if you need to modify
72-
something beyond just the class name, you should use a compiler pass::
40+
If you want to modify service definitions of another bundle, you can use a compiler
41+
pass to change the class of the service or to modify method calls. In the following
42+
example, the implementing class for the ``original-service-id`` is changed to
43+
``Acme\DemoBundle\YourService``::
7344

7445
// src/Acme/DemoBundle/DependencyInjection/Compiler/OverrideServiceCompilerPass.php
7546
namespace Acme\DemoBundle\DependencyInjection\Compiler;
@@ -86,12 +57,7 @@ something beyond just the class name, you should use a compiler pass::
8657
}
8758
}
8859

89-
In this example you fetch the service definition of the original service, and set
90-
its class name to your own class.
91-
92-
See :doc:`/service_container/compiler_passes` for information on how to use
93-
compiler passes. If you want to do something beyond just overriding the class,
94-
like adding a method call, you can only use the compiler pass method.
60+
For more information on compiler passes, see :doc:`/service_container/compiler_passes`.
9561

9662
Entities & Entity Mapping
9763
-------------------------

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.