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