8000 use short config syntax for factories · symfony/symfony-docs@9348d16 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9348d16

Browse files
Henry Snoekxabbuh
Henry Snoek
authored andcommitted
use short config syntax for factories
1 parent 075df7e commit 9348d16

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

service_container/factories.rst

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ configure the service container to use the
5252
app.newsletter_manager:
5353
class: AppBundle\Email\NewsletterManager
5454
# call a method on the specified service
55-
factory: ['@app.newsletter_manager_factory', createNewsletterManager]
55+
factory: 'app.newsletter_manager_factory:createNewsletterManager'
5656
5757
.. code-block:: xml
5858
@@ -111,6 +111,19 @@ configure the service container to use the
111111
the configured class name may be used by compiler passes and therefore
112112
should be set to a sensible value.
113113

114+
.. note::
115+
116+
The traditional configuration syntax in YAML files used an array to define
117+
the factory service and the method name:
118+
119+
.. code-block:: yaml
120+
121+
app.newsletter_manager:
122+
# new syntax
123+
factory: 'app.newsletter_manager_factory:createNewsletterManager'
124+
# old syntax
125+
factory: ['@app.newsletter_manager_factory', createNewsletterManager]
126+
114127
Passing Arguments to the Factory Method
115128
---------------------------------------
116129

@@ -127,7 +140,7 @@ method in the previous example takes the ``templating`` service as an argument:
127140
128141
app.newsletter_manager:
129142
class: AppBundle\Email\NewsletterManager
130-
factory: ['@newsletter_manager_factory', createNewsletterManager]
143+
factory: 'newsletter_manager_factory:createNewsletterManager'
131144
arguments: ['@templating']
132145
133146
.. code-block:: xml

0 commit comments

Comments
 (0)
0