By default, routes look something like this:
cerad_player_wanabe_list: pattern: /player-request/list defaults: _controller: CeradPlayerWanabeBundle:Player/PlayerList:list
The Symfony \ Component \ HttpKernel \ HttpKernel :: handle ($ request) method retrieves the _controller attribute from the request object. If the attribute has two colons, it translates the attribute into the class name and creates an instance using the new operator. If the instance implements ContainerAwareInterface, the container is injected into the controller instance. The controller service you defined is not used. Therefore, the error that the argument is not passed to the constructor.
On the other hand, if _controller has only one colon, then the controller is pulled out as a service from the container. Checking ContainerAwareInterface is not performed. It is up to you to inject dependencies through the service definition.
All of this is documented in: http://symfony.com/doc/current/cookbook/controller/service.html
So, for this particular question, your route should look something like this:
cerad_player_wanabe_list: pattern: /player-request/list defaults: _controller: acme.controller.company:action
This begs the question of why you are trying to define the controller as a service. The default approach already does exactly what you want you to not type.
The rationale for defining services as containers is that you can precisely control the dependencies that the controller uses. Makes the controller more understandable and tested.
Enabling a full container greatly destroys the value of defining a controller as a service.
Cerad Oct 08 '14 at 18:51 2014-10-08 18:51
source share