File tree 2 files changed +12
-41
lines changed
components/dependency_injection
2 files changed +12
-41
lines changed Original file line number Diff line number Diff line change @@ -182,44 +182,3 @@ service by asking for the ``bar`` service like this::
182
182
foo :
183
183
class : Example\Foo
184
184
bar : " @foo"
185
-
186
-
187
- Requiring Files
188
- ---------------
189
-
190
- There might be use cases when you need to include another file just before
191
- the service itself gets loaded. To do so, you can use the ``file `` directive.
192
-
193
- .. configuration-block ::
194
-
195
- .. code-block :: yaml
196
-
197
- services :
198
- foo :
199
- class : Example\Foo\Bar
200
- file : " %kernel.root_dir%/src/path/to/file/foo.php"
201
-
202
- .. code-block :: xml
203
-
204
- <?xml version =" 1.0" encoding =" UTF-8" ?>
205
- <container xmlns =" http://symfony.com/schema/dic/services"
206
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
207
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
208
-
209
- <services >
210
- <service id =" foo" class =" Example\Foo\Bar" >
211
- <file >%kernel.root_dir%/src/path/to/file/foo.php</file >
212
- </service >
213
- </services >
214
- </container >
215
-
216
- .. code-block :: php
217
-
218
- use Symfony\Component\DependencyInjection\Definition;
219
-
220
- $definition = new Definition('Example\Foo\Bar');
221
- $definition->setFile('%kernel.root_dir%/src/path/to/file/foo.php');
222
- $container->setDefinition('foo', $definition);
223
-
224
- Notice that Symfony will internally call the PHP statement ``require_once ``,
225
- which means that your file will be included only once per request.
Original file line number Diff line number Diff line change @@ -125,3 +125,15 @@ You can also replace any existing method calls with an array of new ones with::
125
125
the container is compiled. Once the container is compiled you cannot
126
126
manipulate service definitions further. To learn more about compiling
127
127
the container see :doc: `/components/dependency_injection/compilation `.
128
+
129
+ Requiring Files
130
+ ~~~~~~~~~~~~~~~
131
+
132
+ There might be use cases when you need to include another file just before
133
+ the service itself gets loaded. To do so, you can use the
134
+ :method: `Symfony\\ Component\\ DependencyInjection\\ Definition::setFile ` method::
135
+
136
+ $definition->setFile('/src/path/to/file/foo.php');
137
+
138
+ Notice that Symfony will internally call the PHP statement ``require_once ``,
139
+ which means that your file will be included only once per request.
You can’t perform that action at this time.
0 commit comments