Symonfy: How to use doctrine manager in form subscriber?
<p>I have a form subscriber, i want to use doctrine manager in it. but i got the error message:</p>

<pre><code>"Catchable Fatal Error: Argument 1 passed to ...\ProductEavAttributesSubscriber::__construct() must be an instance of Doctrine\ORM\EntityManager, instance of Symfony\Component\Form\FormFactory given。
</code></pre>

<p>there is my subscriber file code:</p>

<pre><code>namespace Demo\Bundle\ProductBundle\EventListener;

use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\EntityManager;

class ProductEavAttributesSubscriber implements EventSubscriberInterface
{
    private $entityManager;

    public function __construct(EntityManager $entityManager)
    {
        $this-&gt;entityManager = $entityManager;
    }
// coding
}
</code></pre>

<p>in service.yml</p>

<pre><code>demo.product.eav.attribute:
    class: ...\EventListener\ProductEntityAttributesSubscriber
    arguments: ["@doctrine.orm.entity_manager"]
    tags:
        - { name: form.type, alias: product_eav_attribute }
</code></pre>

<p>In form type:</p>

<pre><code>$builder-&gt;add('specifications', ProductEavAttributeType::class);
</code></pre>

<p>In the ProductEavAttributeType file:</p>

<pre><code>class ProductEavAttributeType extends AbstractType
{
    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $factory = $builder-&gt;getFormFactory();
        $productEavAttributes = new ProductEavAttributesSubscriber($factory);
        $builder-&gt;addEventSubscriber($productEavAttributes);
    }
}
</code></pre>

<p>So, how to do now?</p>