Kyle
Kyle

Reputation: 164

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!

Upvotes: 6

Views: 6239

Answers (1)

user8709
user8709

Reputation: 1352

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

Upvotes: 3

Related Questions