@@ -266,23 +266,61 @@ configuration inside a bundle must be included manually. For example, to
266
266
include a routing resource from a bundle called ``AcmeDemoBundle ``, you can
267
267
do the following:
268
268
269
- .. code-block :: yaml
269
+ .. configuration-block ::
270
+
271
+ .. code-block :: yaml
272
+
273
+ # app/config/routing.yml
274
+ _hello :
275
+ resource : " @AcmeDemoBundle/Resources/config/routing.yml"
276
+
277
+ .. code-block :: xml
278
+
279
+ <!-- app/config/routing.yml -->
280
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
281
+
282
+ <routes xmlns =" http://symfony.com/schema/routing"
283
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
284
+ xsi : schemaLocation =" http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd" >
270
285
271
- # app/config/routing.yml
272
- _hello :
273
- resource : " @AcmeDemoBundle/Resources/config/routing.yml"
286
+ <import resource =" @AcmeDemoBundle/Resources/config/routing.xml" />
287
+ </routes >
288
+
289
+ .. code-block :: php
290
+
291
+ // app/config/routing.php
292
+ use Symfony\Component\Routing\RouteCollection;
293
+
294
+ $collection = new RouteCollection();
295
+ $collection->addCollection($loader->import("@AcmeHelloBundle/Resources/config/routing.php"));
296
+
297
+ return $collection;
274
298
275
299
This will load the routes found in the ``Resources/config/routing.yml `` file
276
300
of the ``AcmeDemoBundle ``. The special ``@AcmeDemoBundle `` is a shortcut syntax
277
301
that, internally, resolves to the full path to that bundle.
278
302
279
303
You can use this same strategy to bring in configuration from a bundle:
280
304
281
- .. code -block :: yaml
305
+ .. configuration -block ::
282
306
283
- # app/config/config.yml
284
- imports :
285
- - { resource: "@AcmeDemoBundle/Resources/config/config.yml" }
307
+ .. code-block :: yaml
308
+
309
+ # app/config/config.yml
310
+ imports :
311
+ - { resource: "@AcmeDemoBundle/Resources/config/config.yml" }
312
+
313
+ .. code-block :: xml
314
+
315
+ <!-- app/config/config.xml -->
316
+ <imports >
317
+ <import resource =" @AcmeDemoBundle/Resources/config/config.xml" />
318
+ </imports >
319
+
320
+ .. code-block :: php
321
+
322
+ // app/config/config.php
323
+ $this->import('@AcmeDemoBundle/Resources/config/config.php')
286
324
287
325
In Symfony2, configuration is a bit like ``app.yml `` in symfony1, except much
288
326
more systematic. With ``app.yml ``, you could simply create any keys you wanted.
@@ -299,10 +337,22 @@ used them in your application:
299
337
In Symfony2, you can also create arbitrary entries under the ``parameters ``
300
338
key of your configuration:
301
339
302
- .. code-block :: yaml
340
+ .. configuration-block ::
341
+
342
+ .. code-block :: yaml
343
+
344
+ parameters :
345
+ email.from_address : [email protected]
346
+
347
+ .. code-block :: xml
348
+
349
+ <parameters >
350
+ <parameter key =" email.from_address" >[email protected] </parameter >
351
+ </parameters >
352
+
353
+ .. code-block :: php
303
354
304
- parameters :
305
- email.from_address : [email protected]
355
+ $container->setParameter('email.from_address', '[email protected] ');
306
356
307
357
You can now access this from a controller, for example::
308
358
0 commit comments