@@ -121,7 +121,8 @@ be specified in YAML, XML or PHP:
121
121
<?xml version =" 1.0" encoding =" UTF-8" ?>
122
122
<container xmlns =" http://symfony.com/schema/dic/services"
123
123
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
124
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
124
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
125
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
125
126
126
127
<services >
127
128
<service id =" my_mailer" class =" Acme\HelloBundle\Mailer" >
@@ -216,7 +217,8 @@ straightforward. Parameters make defining services more organized and flexible:
216
217
<?xml version =" 1.0" encoding =" UTF-8" ?>
217
218
<container xmlns =" http://symfony.com/schema/dic/services"
218
219
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
219
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
220
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
221
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
220
222
221
223
<parameters >
222
224
<parameter key =" my_mailer.transport" >sendmail</parameter >
@@ -358,7 +360,8 @@ directories don't exist, create them.
358
360
<?xml version =" 1.0" encoding =" UTF-8" ?>
359
361
<container xmlns =" http://symfony.com/schema/dic/services"
360
362
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
361
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
363
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
364
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
362
365
363
366
<parameters >
364
367
<parameter key =" my_mailer.transport" >sendmail</parameter >
@@ -402,7 +405,8 @@ configuration.
402
405
<?xml version =" 1.0" encoding =" UTF-8" ?>
403
406
<container xmlns =" http://symfony.com/schema/dic/services"
404
407
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
405
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
408
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
409
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
406
410
407
411
<imports >
408
412
<import resource =" @AcmeHelloBundle/Resources/config/services.xml" />
@@ -481,8 +485,10 @@ invokes the service container extension inside the FrameworkBundle:
481
485
<container xmlns =" http://symfony.com/schema/dic/services"
482
486
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
483
487
xmlns : framework =" http://symfony.com/schema/dic/symfony"
484
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
485
- http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
488
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
489
+ http://symfony.com/schema/dic/services/services-1.0.xsd
490
+ http://symfony.com/schema/dic/symfony
491
+ http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
486
492
487
493
<framework : config secret =" xxxxxxxxxx" >
488
494
<framework : form />
@@ -605,6 +611,7 @@ the service container gives you a much more appealing option:
605
611
services :
606
612
my_mailer :
607
613
# ...
614
+
608
615
newsletter_manager :
609
616
class : Acme\HelloBundle\Newsletter\NewsletterManager
610
617
arguments : ["@my_mailer"]
@@ -615,12 +622,14 @@ the service container gives you a much more appealing option:
615
622
<?xml version =" 1.0" encoding =" UTF-8" ?>
616
623
<container xmlns =" http://symfony.com/schema/dic/services"
617
624
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
618
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
625
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
626
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
619
627
620
628
<services >
621
629
<service id =" my_mailer" >
622
630
<!-- ... -->
623
631
</service >
632
+
624
633
<service id =" newsletter_manager" class =" Acme\HelloBundle\Newsletter\NewsletterManager" >
625
634
<argument type =" service" id =" my_mailer" />
626
635
</service >
@@ -634,6 +643,7 @@ the service container gives you a much more appealing option:
634
643
use Symfony\Component\DependencyInjection\Reference;
635
644
636
645
$container->setDefinition('my_mailer', ...);
646
+
637
647
$container->setDefinition('newsletter_manager', new Definition(
638
648
'Acme\HelloBundle\Newsletter\NewsletterManager',
639
649
array(new Reference('my_mailer'))
@@ -686,6 +696,7 @@ Injecting the dependency by the setter method just needs a change of syntax:
686
696
services :
687
697
my_mailer :
688
698
# ...
699
+
689
700
newsletter_manager :
690
701
class : Acme\HelloBundle\Newsletter\NewsletterManager
691
702
calls :
@@ -697,12 +708,14 @@ Injecting the dependency by the setter method just needs a change of syntax:
697
708
<?xml version =" 1.0" encoding =" UTF-8" ?>
698
709
<container xmlns =" http://symfony.com/schema/dic/services"
699
710
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
700
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
711
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
712
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
701
713
702
714
<services >
703
715
<service id =" my_mailer" >
704
716
<!-- ... -->
705
717
</service >
718
+
706
719
<service id =" newsletter_manager" class =" Acme\HelloBundle\Newsletter\NewsletterManager" >
707
720
<call method =" setMailer" >
708
721
<argument type =" service" id =" my_mailer" />
@@ -718,6 +731,7 @@ Injecting the dependency by the setter method just needs a change of syntax:
718
731
use Symfony\Component\DependencyInjection\Reference;
719
732
720
733
$container->setDefinition('my_mailer', ...);
734
+
721
735
$container->setDefinition('newsletter_manager', new Definition(
722
736
'Acme\HelloBundle\Newsletter\NewsletterManager'
723
737
))->addMethodCall('setMailer', array(
@@ -756,12 +770,14 @@ it exists and do nothing if it doesn't:
756
770
<?xml version =" 1.0" encoding =" UTF-8" ?>
757
771
<container xmlns =" http://symfony.com/schema/dic/services"
758
772
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
759
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
773
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
774
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
760
775
761
776
<services >
762
777
<service id =" my_mailer" >
763
778
<!-- ... -->
764
779
</service >
780
+
765
781
<service id =" newsletter_manager" class =" Acme\HelloBundle\Newsletter\NewsletterManager" >
766
782
<argument type =" service" id =" my_mailer" on-invalid =" ignore" />
767
783
</service >
@@ -776,6 +792,7 @@ it exists and do nothing if it doesn't:
776
792
use Symfony\Component\DependencyInjection\ContainerInterface;
777
793
778
794
$container->setDefinition('my_mailer', ...);
795
+
779
796
$container->setDefinition('newsletter_manager', new Definition(
780
797
'Acme\HelloBundle\Newsletter\NewsletterManager',
781
798
array(
@@ -863,7 +880,8 @@ Configuring the service container is easy:
863
880
<?xml version =" 1.0" encoding =" UTF-8" ?>
864
881
<container xmlns =" http://symfony.com/schema/dic/services"
865
882
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
866
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
883
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
884
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
867
885
868
886
<service id =" newsletter_manager" class =" Acme\HelloBundle\Newsletter\NewsletterManager" >
869
887
<argument type =" service" id =" mailer" />
@@ -912,6 +930,7 @@ to be used for a specific purpose. Take the following example:
912
930
services :
913
931
foo.twig.extension :
914
932
class : Acme\HelloBundle\Extension\FooExtension
933
+ public : false
915
934
tags :
916
935
- { name: twig.extension }
917
936
@@ -921,11 +940,13 @@ to be used for a specific purpose. Take the following example:
921
940
<?xml version =" 1.0" encoding =" UTF-8" ?>
922
941
<container xmlns =" http://symfony.com/schema/dic/services"
923
942
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
924
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
943
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
944
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
925
945
926
946
<service
927
947
id =" foo.twig.extension"
928
- class =" Acme\HelloBundle\Extension\FooExtension" >
948
+ class =" Acme\HelloBundle\Extension\FooExtension"
949
+ public =" false" >
929
950
930
951
<tag name =" twig.extension" />
931
952
</service >
@@ -937,6 +958,7 @@ to be used for a specific purpose. Take the following example:
937
958
use Symfony\Component\DependencyInjection\Definition;
938
959
939
960
$definition = new Definition('Acme\HelloBundle\Extension\FooExtension');
961
+ $definition->setPublic(false);
940
962
$definition->addTag('twig.extension');
941
963
$container->setDefinition('foo.twig.extension', $definition);
942
964
0 commit comments