Symfony3 Factory as Service
<p>I have been trying to get my head around this</p>

<p><a href="http://symfony.com/doc/current/service_container/factories.html" rel="noreferrer">http://symfony.com/doc/current/service_container/factories.html</a></p>

<p>But there seems to be a piece missing that tires it all together <em>OR</em> I am completely missing the point.</p>

<p>The example has a factory Class</p>

<pre><code>class NewsletterManagerFactory
{
    public static function createNewsletterManager()
    {
        $newsletterManager = new NewsletterManager();

        // ...

        return $newsletterManager;
    }
}
</code></pre>

<p>And then that factory is configured via a service to be the factory class and method for <code>NewsletterManager</code> service.</p>

<pre><code>services:
    app.newsletter_manager_factory:
        class: AppBundle\Email\NewsletterManagerFactory

    app.newsletter_manager:
        class:   AppBundle\Email\NewsletterManager
        factory: 'app.newsletter_manager_factory:createNewsletterManager'
</code></pre>

<p>So now we have a <code>NewsletterManager</code> Class that is aware of the <code>NewsletterManagerFactory</code> Class via the <code>factory:</code> param in <code>services.yml</code></p>

<p><strong>Question</strong></p>

<p>How do you make use of this configuration? What is now exposed inside of <code>NewsletterManager</code> that allows me to call <code>createNewsletterManager</code> in the factory Class?</p>

<p>The two services are still completely separate as far as I can tell?</p>