deymaz
deymaz

Reputation: 21

Symfony Argument error wgen i'm added event subscriber

I have a constructor for controller which gelp me handle

use Doctrine\ORM\EntityManagerInterface;

   private $repository;

    public function __construct(EntityManagerInterface $em)
    {
       $this->repository =  $em->getRepository(Interview::class);
    }

And all work fine until i add event subscribers in services.yml:

services:
  AppBundle\EventListener\InterviewListener:
        tags:
            - { name: event_subscriber}

after this my app generate error:

Type error: Argument 1 passed to AppBundle\Controller\InterviewController::__construct() must be an instance of Doctrine\ORM\EntityManagerInterface, none given, called in /home/deymaz/Dev/interview/interview/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php on line 195

Upvotes: 0

Views: 109

Answers (1)

Alister Bulman
Alister Bulman

Reputation: 35169

Your InterviewListener service config (in services.yml) will either need autoconfiguration setup, or to add the relevant argument.

If you are running Symfony 3.3+, with autowiring enabled, and the class implements EventSubscriberInterface then the rest of the config may not be needed, as it would already be configured automatically.

Upvotes: 0

Related Questions