From the official documentation ( http://symfony.com/doc/current/quick_tour/the_view.html#embedding-other-controllers ) I learned how to embed a controller in a Twig template.
The problem occurs when the controller enters properties. Is there a way to use the Twig render(controller()) function with controllers that have a constructor?
When I try to do the following:
{{ render(controller( 'SomeBundle:Some:renderList', { 'request': app.request } )) }}
I get this error: Missing argument 1 for SomeBundle\Controller\SomeController::__construct()
The constructor for this controller is as follows:
public function __construct($container, SomeService $someService) { parent::__construct($container); $this->someService = $someService; }
Container injection and someService is configured in service.yml.
So, again, my question is: how to embed a controller in a Twig template when this controller uses Injection Dependency?
UPDATE
I could do this: {{ render(app.request.baseUrl ~ '/some/route') }} But I would like to avoid routes.
UPDATE 2
Service definition from service.yml
some.controller: class: SomeBundle\Controller\SomeController arguments: ["@service_container", "@some.service"]
source share