PedroHCan
PedroHCan

Reputation: 1067

Symfony2 service param constructor error

I am using symfony2 and I use one service to notify my users based in some action sof the system. Well, It worked pretty fine in my local environment, now in production I am having some issues.

The service is dlecared on services.txt as:

mybundle.notify:
    class: NC8Digital\CRMBundle\Services\Notify
    arguments: [ @doctrine.orm.entity_manager, @templating, @mailer ]

And the class is declared as

public function __construct(EntityManager $em, TimedTwigEngine $templating, \Swift_Mailer $mailer)

And I am receiving this error:

PHP Catchable fatal error:  Argument 2 passed to NC8Digital\\CRMBundle\\Services\\Notify::__construct() must be an instance of Symfony\\Bundle\\TwigBundle\\Debug\\TimedTwigEngine, instance of Symfony\\Bundle\\TwigBundle\\TwigEngine given, called in /mypath/app/cache/prod/appProdProjectContainer.php on line 367 and defined in /mypath/src/NC8Digital/CRMBundle/Services/Notify.php on line 43

First thing I tried was to change my constructor to solve the problem... got a 500 error on my browser, so I changed back.

Upvotes: 2

Views: 1119

Answers (1)

Elnur Abdurrakhimov
Elnur Abdurrakhimov

Reputation: 44841

Type-hint the second parameter with Symfony\Bundle\FrameworkBundle\Templating\EngineInterface.

Upvotes: 4

Related Questions