Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using constructor injection in controller doesn't work #990

Closed
danielrvt opened this issue Mar 13, 2015 · 1 comment
Closed

Using constructor injection in controller doesn't work #990

danielrvt opened this issue Mar 13, 2015 · 1 comment

Comments

@danielrvt
Copy link

When using constructor injection in my controllers, automatic route generation is not allowing constructor injection, instead of the bundle:controller:action convention, it should use the service_name:actionAction convention.

For instace, supose I have this controller as a service:

    dnd_agent_controller:
        class: DnD\RaHApiBundle\Controller\AgentController
        arguments: ["@dnd_agent_repository", "@service_container"]

Then, with this routing:

agents_resource:
    type: rest
     resource: DnD\RaHApiBundle\Controller\AgentController

I'm not getting the dependency injected into my controller. However, If I use the following routing:

agents_resource:
  path: /agents
  defaults: { _controller: dnd_agent_controller:getallAction}

I do get the dependency injected, but using this, I'm bypassing the automatic route generation.

@danielrvt danielrvt reopened this Mar 13, 2015
@lsmith77
Copy link
Member

simply specify the service name as the resource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants