diff --git a/components/dependency_injection/factories.rst b/components/dependency_injection/factories.rst index 6727bc838a5..7a22ba17da2 100644 --- a/components/dependency_injection/factories.rst +++ b/components/dependency_injection/factories.rst @@ -68,6 +68,14 @@ class: $container->setDefinition('newsletter_manager', $definition); +.. note:: + + When using a factory to create services, the value chosen for the ``class`` + option has no effect on the resulting service. The actual class name only + depends on the object that is returned by the factory. However, the configured + class name may be used by compiler passes and therefore should be set to a + sensible value. + When you specify the class to use for the factory (via ``factory_class``) the method will be called statically. If the factory itself should be instantiated and the resulting object's method called, configure the factory itself as a service.