Symfony 2.7中的弃用警告

时间:2015-06-03 16:06:04

标签: php symfony 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中执行此操作的正确方法是什么?

2 个答案:

答案 0 :(得分:4)

您必须将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

答案 1 :(得分:1)