如何避免 "knp_menu.factory" 弃用?

How to avoid "knp_menu.factory" deprecation?

我正在尝试将 KNPMenuBundleSumfony 3.3 一起使用,但我收到了这个恼人的警告:

Autowiring services based on the types they implement is deprecated since Symfony 3.3 and won't be supported in version 4.0. You should rename (or alias) the "knp_menu.factory" service to "Knp\Menu\FactoryInterface" instead.

Trace: {..../vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php:344: }

我根本没有设置这个knp_menu.factory,可能是bundle自动设置的。

我是否需要配置任何东西才能使此警告消失?

我是这样解决的:

app.component_menu.builder:
    class: AppBundle\Component\Menu\Builder
    arguments: ['@knp_menu.factory', '@event_dispatcher']
    calls:
        - [setAuthorizationChecker, ['@security.authorization_checker']]


Knp\Menu\ItemInterface:
    class: Knp\Menu\MenuItem
    factory: ['@app.component_menu.builder', mainMenu]
    arguments: ['@knp_menu.matcher']
    tags:
        - { name: knp_menu.menu, alias: main }

Knp\Menu\FactoryInterface:
    alias: knp_menu.factory
    public: false

不确定这是否是推荐的解决方案,但它删除了弃用通知。