使用工厂创建带有symfony2.7的服务

使用工厂创建带有symfony2.7的服务,symfony,symfony-2.7,Symfony,Symfony 2.7,如何使用factory使用symfony2.7创建服务 #service.yml #in symfony 2.6 my.repository.photo: class: My\AppBundle\Repository\PhotoRepository factory_method: getRepository factory_service: doctrine arguments: [My\AppBundle\Entity\Photo] #I have some

如何使用factory使用symfony2.7创建服务

#service.yml
#in symfony 2.6
my.repository.photo:
    class: My\AppBundle\Repository\PhotoRepository
    factory_method: getRepository
    factory_service: doctrine
    arguments: [My\AppBundle\Entity\Photo]

#I have some errors like this
Deprecated: Symfony\Component\DependencyInjection\Definition::setFactoryMethod(getRepository) is deprecated since version 2.6 and will be removed in 3.0. Use Definition::setFactory() instead. in /my/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Definition.php on line 137
Deprecated: Symfony\Component\DependencyInjection\Definition::setFactoryService(doctrine) is deprecated since version 2.6 and will be removed in 3.0. Use Definition::setFactory() instead. in my/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Definition.php on line 208
在我的案例中,现在如何使用“setFactory”方法? 文件:


谢谢

我认为相关文档很清楚。尝试以下配置:

my.repository.photo:
    class: My\AppBundle\Repository\PhotoRepository
    factory: ["@doctrine", getRepository]
    arguments: [My\AppBundle\Entity\Photo]
不推荐的错误是升级Symfony 3.0的准备。某些功能(如factory|u服务| factory|u方法)将被删除。这里有一个线程,如果你真的不需要它,你可以找到解决方案