8000 minor #7213 use short config syntax for factories (snoek09) · symfony/symfony-docs@6dd3291 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 6dd3291

Browse files
committed
minor #7213 use short config syntax for factories (snoek09)
This PR was submitted for the 3.2 branch but it was merged into the 2.7 branch instead (closes #7213). Discussion ---------- use short config syntax for factories This fixes #7208. Commits ------- 9348d16 use short config syntax for factories
2 parents 075df7e + 9348d16 commit 6dd3291

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