“服务”;app.locale_listener";必须实现接口


Service "app.locale_listener" must implement interface

我正试图在symfony2应用程序上使用粘性区域设置更改。使用官方文档中的本指南。

但我得到了一个错误:

Service "app.locale_listener" must implement interface "Symfony'Component'EventDispatcher'EventSubscriberInterface".

问题是这个类已经实现了EventSubscriberInterface

public static function getSubscribedEvents()
    {
        return array(
            // must be registered after the default Locale listener
            KernelEvents::REQUEST => array(array('onKernelRequest', 15)),
        );
    }

我正在使用Symfony 2.8

有人遇到这个错误吗?

这是因为你有

tags:
            - {name: kernel.event_subscriber}

在您的服务中配置service.yaml。把它拿出来,错误就消失了。