@@ -135,7 +135,20 @@ the service container *how* to instantiate it:
135
135
.. code-block :: xml
136
136
137
137
<!-- app/config/services.xml -->
138
- TODO
138
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
139
+ <container xmlns =" http://symfony.com/schema/dic/services"
140
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
141
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
142
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
143
+
144
+ <services >
145
+ <!-- Default configuration for services in *this* file -->
146
+ <defaults autowire =" true" autoconfigure =" true" />
147
+
148
+ <!-- Load services from whatever directories you want (you can update this!) -->
149
+ <prototype namespace =" AppBundle\" resource =" ../../src/AppBundle/{Service,EventDispatcher,Twig,Form}" />
150
+ </services >
151
+ </container >
139
152
140
153
.. code-block :: php
141
154
@@ -284,7 +297,19 @@ the new ``Updates`` sub-directory:
284
297
.. code-block :: xml
285
298
286
299
<!-- app/config/services.xml -->
287
- TODO
300
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
301
+ <container xmlns =" http://symfony.com/schema/dic/services"
302
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
303
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
304
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
305
+
306
+ <services >
307
+ <!-- ... -->
308
+
309
+ <!-- Registers all classes in Services & Updates directories -->
310
+ <prototype namespace =" AppBundle\" resource =" ../../src/AppBundle/{Service,Updates,EventDispatcher,Twig,Form}" />
311
+ </services >
312
+ </container >
288
313
289
314
.. code-block :: php
290
315
@@ -375,7 +400,24 @@ pass here. No problem! In your configuration, you can explicitly set this argume
375
400
.. code-block :: xml
376
401
377
402
<!-- app/config/services.xml -->
378
- TODO
403
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
404
+ <container xmlns =" http://symfony.com/schema/dic/services"
405
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
406
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
407
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
408
+
409
+ <services >
410
+ <!-- ... -->
411
+
412
+ <!-- Same as before -->
413
+ <prototype namespace =" AppBundle\" resource =" ../../src/AppBundle/{Service,Updates}" />
414
+
415
+ <!-- Explicitly configure the service -->
416
+ <service id =" AppBundle\Updates\SiteUpdateManager" >
417
+ <argument key =" $adminEmail" >%admin_email%</argument >
418
+ </service >
419
+ </services >
420
+ </container >
379
421
380
422
.. code-block :: php
381
423
@@ -412,7 +454,25 @@ and reference it with the ``%parameter_name%`` syntax:
412
454
413
455
.. code-block :: xml
414
456
415
- TODO
457
+ <!-- app/config/services.xml -->
458
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
459
+ <container xmlns =" http://symfony.com/schema/dic/services"
460
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
461
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
462
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
463
+
464
+ <parameters >
465
+ <parameter key =" admin_email" >manager@example.com</parameter >
466
+ </parameters >
467
+
468
+ <services >
469
+ <!-- ... -->
470
+
471
+ <service id =" AppBundle\Updates\SiteUpdateManager" >
472
+ <argument key =" $adminEmail" >%admin_email%</argument >
473
+ </service >
474
+ </services >
475
+ </container >
416
476
417
477
.. code-block :: php
418
478
@@ -495,7 +555,21 @@ But, you can control this and pass in a different logger:
495
555
.. code-block :: xml
496
556
497
557
<!-- app/config/services.xml -->
498
- TODO
558
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
559
+ <container xmlns =" http://symfony.com/schema/dic/services"
560
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
561
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
562
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
563
+
564
+ <services >
565
+ <!-- ... same code as before -->
566
+
567
+ <!-- Explicitly configure the service -->
568
+ <service id =" AppBundle\Service\MessageGenerator" >
569
+ <argument key =" $logger" type =" service" id =" monolog.logger.request" />
570
+ </service >
571
+ </services >
572
+ </container >
499
573
500
574
.. code-block :: php
501
575
@@ -538,7 +612,20 @@ as a service, and :doc:`tag </service_container/tags>` it with ``twig.extension`
538
612
.. code-block :: xml
539
613
540
614
<!-- app/config/services.xml -->
541
- TODO
615
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
616
+ <container xmlns =" http://symfony.com/schema/dic/services"
617
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
618
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
619
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
620
+
621
+ <services >
622
+ <!-- ... -->
623
+
624
+ <service id =" AppBundle\Twig\MyTwigExtension" >
625
+ <tag name =" twig.extension" />
626
+ </service >
627
+ </services >
628
+ </container >
542
629
543
630
.. code-block :: php
544
631
@@ -565,7 +652,19 @@ is this:
565
652
.. code-block :: xml
566
653
567
654
<!-- app/config/services.xml -->
568
- TODO
655
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
656
+ <container xmlns =" http://symfony.com/schema/dic/services"
657
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
658
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
659
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
660
+
661
+ <services >
662
+ <defaults autowire =" true" autoconfigure =" true" />
663
+
664
+ <!-- Load your services-->
665
+ <prototype namespace =" AppBundle\" resource =" ../../src/AppBundle/{Service,EventDispatcher,Twig,Form}" />
666
+ </services >
667
+ </container >
569
668
570
669
.. code-block :: php
571
670
0 commit comments