Skip to content

Commit 66cf990

Browse files
committed
minor #5018 Added a note about the class option of the services defined via factories (javiereguiluz)
This PR was merged into the 2.3 branch. Discussion ---------- Added a note about the class option of the services defined via factories | Q | A | ------------- | --- | Doc fix? | no | New docs? | yes | Applies to | 2.3+ | Fixed tickets | #4368 The original comment by @xabbuh in #4368 explained everything so well, that I decided to just copy it. Commits ------- 2551322 Rewording 90956cc Minor rewording 477da91 Minor rewording 27ca372 Added a note about the class option of the services defined via factories
2 parents 32b6228 + 2551322 commit 66cf990

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

components/dependency_injection/factories.rst

+8
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ class:
6868
6969
$container->setDefinition('newsletter_manager', $definition);
7070
71+
.. note::
72+
73+
When using a factory to create services, the value chosen for the ``class``
74+
option has no effect on the resulting service. The actual class name only
75+
depends on the object that is returned by the factory. However, the configured
76+
class name may be used by compiler passes and therefore should be set to a
77+
sensible value.
78+
7179
When you specify the class to use for the factory (via ``factory_class``)
7280
the method will be called statically. If the factory itself should be instantiated
7381
and the resulting object's method called, configure the factory itself as a service.

0 commit comments

Comments
 (0)