Reputation: 11265
I'm trying to enject doctrine in controller:
This is my services:
services:
default_controller:
class: Catalog\WebBundle\Controller\DefaultController
arguments: [@doctrine.orm.entity_manager]
Controller:
public function __construct(EntityManager $em)
{
}
CRITICAL - Uncaught PHP Exception ErrorException: "Catchable Fatal Error: Argument 1 passed to Catalog\WebBundle\Controller\DefaultController::__construct() must be an instance of Doctrine\ORM\EntityManager, none given, called in /home/katalogas/domains/example.com/public_html/app/cache/dev/classes.php on line 2783 and defined in /home/katalogas/domains/example.com/public_html/src/Catalog/WebBundle/Controller/DefaultController.php line 23" at /home/katalogas/domains/example.com/public_html/src/Catalog/WebBundle/Controller/DefaultController.php line 23 Context: {"exception":"Object(ErrorException)"}
I'm sure that my service.yml is loaded, because when I make typo - get parse error.
Upvotes: 0
Views: 80
Reputation: 1391
You have probably set the controller for your route using the controller notation e.g: SomeBundle:SomeController:SomeAction
you have to use the service notation in your routing.i.e:
# when defining your route in yml
...
{ _controller: default_controller:someAction ...}
Upvotes: 2
Reputation: 159
I use this syntax it works.
arguments:
- @doctrine.orm.default_entity_manager
Upvotes: 1