Symfony 2.7 中的弃用警告

Deprecation warning in Symfony 2.7

我最近更新到 Symfony 2.7 并 运行 解决了这个问题。它给我这个弃用错误。

Symfony\Component\DependencyInjection\Definition::setFactoryMethod(getRepository) is deprecated since version 2.6 and will be removed in 3.0. Use Definition::setFactory() instead

Symfony\Component\DependencyInjection\Definition::setFactoryService(doctrine.orm.entity_manager) is deprecated since version 2.6 and will be removed in 3.0. Use Definition::setFactory() instead

似乎是这个配置的罪魁祸首。

ac_queue.failed.job.repository:
    class: Acme\Bundle\QueueBundle\Repository\FailedJob
    factory_service: doctrine.orm.entity_manager
    factory_method: getRepository
    arguments: ['AcmeQueueBundle:FailedJob']
    public: false

现在在 Symfony 2.7 中执行此操作的正确方法是什么?

KNPUniversity 在这篇文章中涵盖了这个弃用错误:

http://knpuniversity.com/blog/upgrading-symfony-2.7#you-need-to-upgrade-sensio-distribution-bundle

您必须将 factory_servicefactory_method 转换为 factory 参数:

ac_queue.failed.job.repository:
    class: Acme\Bundle\QueueBundle\Repository\FailedJob
    factory: [@doctrine.orm.entity_manager, getRepository]
    arguments: ['AcmeQueueBundle:FailedJob']
    public: false