@@ -7,13 +7,6 @@ How to Override any Part of a Bundle
7
7
This document is a quick reference for how to override different parts of
8
8
third-party bundles.
9
9
10
- .. note ::
11
-
12
- Whenever you are extending a (part of a) bundle, make sure that your bundle
13
- is registered in the kernel **after ** the bundle you're trying to override
14
- parts of. Otherwise, your config that is supposed to override bundle
15
- configuration, is instead overridden by it!
16
-
17
10
Templates
18
11
---------
19
12
@@ -42,15 +35,24 @@ inheritance. For more information, see :doc:`/cookbook/bundles/inheritance`.
42
35
Services & Configuration
43
36
------------------------
44
37
38
+ .. note ::
39
+
40
+ Whenever you are extending a (part of a) bundle, make sure that your bundle
41
+ is registered in the kernel **after ** the bundle you're trying to override
42
+ parts of. Otherwise, your config that is supposed to override bundle
43
+ configuration, is instead overridden by it!
44
+
45
45
In order to completely override a service, just define the service as you would
46
46
usual, but making sure the id of the service is identical to the one you are
47
47
overriding.
48
48
49
49
In order to extend a service (e.g. just add a method, but leaving the
50
50
dependencies or tags intact), make sure the class name is defined as a parameter
51
- in the service config of the bundle containing the service. Then, in your bundle
52
- you can override the class name by setting the parameter directly in the
53
- container in the Extension class of your bundle:
51
+ in the service config of the bundle containing the service. You can then either
52
+ set this parameter in your config.yml, or, if you're going to reuse your bundle
53
+ and it should always override the class, in your bundle you can override the
54
+ class name by setting the parameter directly in the container in the Extension
55
+ class of your bundle:
54
56
55
57
.. code-block :: html+php
56
58
<?php
@@ -77,6 +79,10 @@ container in the Extension class of your bundle:
77
79
}
78
80
}
79
81
82
+ If you want to do something beyond just overriding a parameter - like adding a
83
+ method call - it must be done as a compiler pass. See
84
+ `/cookbook/service_container/compiler_passes `
85
+
80
86
Entities & Entity mapping
81
87
-------------------------
82
88
0 commit comments