将Doctrine Entity Manager传递给服务

时间:2011-12-01 06:03:05

标签: symfony doctrine-orm

我想传入Doctrine Entity Manager,以便我可以访问我的存储库等,但我遇到了一些麻烦。

我的服务已定义:

mlbp_beer.rest.controller:
    class: MLBP\BeerBundle\Controller\RestController
    arguments: 
      em: "@doctrine.orm.entity_manager" 

这给了我一个错误:

ParameterNotFoundException: The service "mlbp_beer.rest.controller" has a dependency on a non-existent parameter "doctrine.orm.entity_manager".

感谢您的帮助!

1 个答案:

答案 0 :(得分:3)

看起来不错?确保在routing.yml中定义了rest,就像这样。也清除缓存!

rest:
    resource: mlbp_beer.rest.controller
    type:     rest