Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass Doctrine Entity Manager to a Service

I want to pass in the Doctrine Entity Manager so I can access my repositories etc. but I'm having some trouble.

My service is defined:

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

This gives me an error:

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

Thanks for the help!

like image 811
Kyle Avatar asked Dec 01 '11 06:12

Kyle


1 Answers

That looks right? Make sure rest is defined in your routing.yml like so.. Clear the cache too!

rest:
    resource: mlbp_beer.rest.controller
    type:     rest
like image 175
user8709 Avatar answered Oct 04 '22 03:10

user8709