Skip to content

Commit 27ca372

Browse files
committed
Added a note about the class option of the services defined via factories
1 parent e5dbd49 commit 27ca372

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

components/dependency_injection/factories.rst

+7
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ class:
6868
6969
$container->setDefinition('newsletter_manager', $definition);
7070
71+
.. note::
72+
73+
When creating a service through a factory, the value chosen for the ``class``
74+
option has no actual effect since the final class only depends on the object
75+
returned by the factory. However, the configured class may be used by compiler
76+
passes and therefore should be set to a sensible value.
77+
7178
When you specify the class to use for the factory (via ``factory_class``)
7279
the method will be called statically. If the factory itself should be instantiated
7380
and the resulting object's method called, configure the factory itself as a service.

0 commit comments

Comments
 (0)