Symfony 3.4 autowire service Symfony 3.4 autowire service symfony symfony

Symfony 3.4 autowire service


As noted by @Cerad in the comments, you should change EntityManager to EntityManagerInterface in your constructor.

Change the line

use Doctrine\ORM\EntityManager;

to

use Doctrine\ORM\EntityManagerInterface;

And also change the line

public function __construct(FormFactoryInterface $formFactory, EntityManager $em, RouterInterface $router)

to

public function __construct(FormFactoryInterface $formFactory, EntityManagerInterface $em, RouterInterface $router)


The Doctrine\Common\Persistence\ObjectManager interface is no longer aliased to the doctrine.orm.entity_manager service, use Doctrine\ORM\EntityManagerInterface instead.