@@ -183,7 +183,8 @@ straightforward. Parameters make defining services more organized and flexible:
183
183
<?xml version =" 1.0" encoding =" UTF-8" ?>
184
184
<container xmlns =" http://symfony.com/schema/dic/services"
185
185
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
186
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
186
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
187
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
187
188
188
189
<parameters >
189
190
<parameter key =" my_mailer.transport" >sendmail</parameter >
@@ -317,7 +318,8 @@ directories don't exist, create them.
317
318
<?xml version =" 1.0" encoding =" UTF-8" ?>
318
319
<container xmlns =" http://symfony.com/schema/dic/services"
319
320
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
320
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
321
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
322
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
321
323
322
324
<parameters >
323
325
<parameter key =" my_mailer.transport" >sendmail</parameter >
@@ -361,7 +363,8 @@ configuration.
361
363
<?xml version =" 1.0" encoding =" UTF-8" ?>
362
364
<container xmlns =" http://symfony.com/schema/dic/services"
363
365
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
364
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
366
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
367
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
365
368
366
369
<imports >
367
370
<import resource =" @AcmeHelloBundle/Resources/config/services.xml" />
@@ -440,8 +443,10 @@ invokes the service container extension inside the FrameworkBundle:
440
443
<container xmlns =" http://symfony.com/schema/dic/services"
441
444
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
442
445
xmlns : framework =" http://symfony.com/schema/dic/symfony"
443
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
444
- http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
446
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
447
+ http://symfony.com/schema/dic/services/services-1.0.xsd
448
+ http://symfony.com/schema/dic/symfony
449
+ http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
445
450
446
451
<framework : config secret =" xxxxxxxxxx" >
447
452
<framework : form />
@@ -564,6 +569,7 @@ the service container gives you a much more appealing option:
564
569
services :
565
570
my_mailer :
566
571
# ...
572
+
567
573
newsletter_manager :
568
574
class : Acme\HelloBundle\Newsletter\NewsletterManager
569
575
arguments : ["@my_mailer"]
@@ -574,12 +580,14 @@ the service container gives you a much more appealing option:
574
580
<?xml version =" 1.0" encoding =" UTF-8" ?>
575
581
<container xmlns =" http://symfony.com/schema/dic/services"
576
582
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
577
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
583
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
584
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
578
585
579
586
<services >
580
587
<service id =" my_mailer" >
581
588
<!-- ... -->
582
589
</service >
590
+
583
591
<service id =" newsletter_manager" class =" Acme\HelloBundle\Newsletter\NewsletterManager" >
584
592
<argument type =" service" id =" my_mailer" />
585
593
</service >
@@ -593,6 +601,7 @@ the service container gives you a much more appealing option:
593
601
use Symfony\Component\DependencyInjection\Reference;
594
602
595
603
$container->setDefinition('my_mailer', ...);
604
+
596
605
$container->setDefinition('newsletter_manager', new Definition(
597
606
'Acme\HelloBundle\Newsletter\NewsletterManager',
598
607
array(new Reference('my_mailer'))
@@ -756,6 +765,7 @@ Injecting the dependency by the setter method just needs a change of syntax:
756
765
services :
757
766
my_mailer :
758
767
# ...
768
+
759
769
newsletter_manager :
760
770
class : Acme\HelloBundle\Newsletter\NewsletterManager
761
771
calls :
@@ -767,12 +777,14 @@ Injecting the dependency by the setter method just needs a change of syntax:
767
777
<?xml version =" 1.0" encoding =" UTF-8" ?>
768
778
<container xmlns =" http://symfony.com/schema/dic/services"
769
779
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
770
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
780
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
781
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
771
782
772
783
<services >
773
784
<service id =" my_mailer" >
774
785
<!-- ... -->
775
786
</service >
787
+
776
788
<service id =" newsletter_manager" class =" Acme\HelloBundle\Newsletter\NewsletterManager" >
777
789
<call method =" setMailer" >
778
790
<argument type =" service" id =" my_mailer" />
@@ -788,6 +800,7 @@ Injecting the dependency by the setter method just needs a change of syntax:
788
800
use Symfony\Component\DependencyInjection\Reference;
789
801
790
802
$container->setDefinition('my_mailer', ...);
803
+
791
804
$container->setDefinition('newsletter_manager', new Definition(
792
805
'Acme\HelloBundle\Newsletter\NewsletterManager'
793
806
))->addMethodCall('setMailer', array(
@@ -924,12 +937,14 @@ it exists and do nothing if it doesn't:
924
937
<?xml version =" 1.0" encoding =" UTF-8" ?>
925
938
<container xmlns =" http://symfony.com/schema/dic/services"
926
939
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
927
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
940
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
941
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
928
942
929
943
<services >
930
944
<service id =" my_mailer" >
931
945
<!-- ... -->
932
946
</service >
947
+
933
948
<service id =" newsletter_manager" class =" Acme\HelloBundle\Newsletter\NewsletterManager" >
934
949
<argument type =" service" id =" my_mailer" on-invalid =" ignore" />
935
950
</service >
@@ -944,6 +959,7 @@ it exists and do nothing if it doesn't:
944
959
use Symfony\Component\DependencyInjection\ContainerInterface;
945
960
946
961
$container->setDefinition('my_mailer', ...);
962
+
947
963
$container->setDefinition('newsletter_manager', new Definition(
948
964
'Acme\HelloBundle\Newsletter\NewsletterManager',
949
965
array(
@@ -1031,7 +1047,8 @@ Configuring the service container is easy:
1031
1047
<?xml version =" 1.0" encoding =" UTF-8" ?>
1032
1048
<container xmlns =" http://symfony.com/schema/dic/services"
1033
1049
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
1034
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
1050
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
1051
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
1035
1052
1036
1053
<service id =" newsletter_manager" class =" Acme\HelloBundle\Newsletter\NewsletterManager" >
1037
1054
<argument type =" service" id =" mailer" />
@@ -1080,6 +1097,7 @@ to be used for a specific purpose. Take the following example:
1080
1097
services :
1081
1098
foo.twig.extension :
1082
1099
class : Acme\HelloBundle\Extension\FooExtension
1100
+ public : false
1083
1101
tags :
1084
1102
- { name: twig.extension }
1085
1103
@@ -1089,11 +1107,13 @@ to be used for a specific purpose. Take the following example:
1089
1107
<?xml version =" 1.0" encoding =" UTF-8" ?>
1090
1108
<container xmlns =" http://symfony.com/schema/dic/services"
1091
1109
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
1092
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
1110
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
1111
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
1093
1112
1094
1113
<service
1095
1114
id =" foo.twig.extension"
1096
- class =" Acme\HelloBundle\Extension\FooExtension" >
1115
+ class =" Acme\HelloBundle\Extension\FooExtension"
1116
+ public =" false" >
1097
1117
1098
1118
<tag name =" twig.extension" />
1099
1119
</service >
@@ -1105,6 +1125,7 @@ to be used for a specific purpose. Take the following example:
1105
1125
use Symfony\Component\DependencyInjection\Definition;
1106
1126
1107
1127
$definition = new Definition('Acme\HelloBundle\Extension\FooExtension');
1128
+ $definition->setPublic(false);
1108
1129
$definition->addTag('twig.extension');
1109
1130
$container->setDefinition('foo.twig.extension', $definition);
1110
1131
0 commit comments