【发布时间】:2018-08-26 22:30:48
【问题描述】:
我有以下课程:
电子邮件通知
namespace App\Component\Notification\RealTimeNotification;
use Symfony\Bridge\Twig\TwigEngine;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use App\Component\Notification\NotificationInterface;
class EmailNotification implements NotificationInterface
{
private $logNotification;
public function __construct(LogNotification $logNotification, \Swift_Mailer $mailer, EngineInterface $twigEngine)
{
$this->logNotification = $logNotification;
}
public function send(array $options): void
{
$this->logNotification->send($options);
dump('Sent to email');
}
}
我的 yml 上有以下服务定义:
app.email_notification:
class: App\Component\Notification\RealTimeNotification\EmailNotification
decorates: app.log_notification
decoration_inner_name: app.log_notification.inner
arguments: ['@app.log_notification.inner', '@mailer', '@templating']
但是,当我尝试运行我的应用程序时,它会抛出一个异常:
无法自动绑定服务 “应用\组件\通知\RealTimeNotification\EmailNotification”: 方法“__construct()”的参数“$twigEngine”具有类型 "Symfony\Bundle\FrameworkBundle\Templating\EngineInterface" 但是这个 找不到类。
为什么会这样?
谢谢!
【问题讨论】: