I'm trying to render an action which is in a sub-namespaced controller from within a Twig view in Symfony 2.
The problem is: The render helper cannot find the controller/action because it's in a namespace below Controller.
This is my controller: src/Acme/Bundle/TestBundle/Controller/FirstModule/ExampleController.php
namespace Acme\Bundle\TestBundle\Controller\FirstModule;
class ExampleController extends Controller
{
public function exampleAction(Request $request)
{
return $this->render('AcmeTestBundle:FirstModuleExample:example.html.twig');
}
public function embedAction(Request $request)
{
return $this->render('AcmeTestBundle:FirstModuleExample:embed.html.twig');
}
}
This is my view: src/Acme/Bundle/TestBundle/Resources/views/FirstModuleExample/example.html.twig
{% render "AcmeTestBundle:Example:embed" %}
// or
{% render "Acme\Bundle\TestBundle\Controller\FirstModule\Example:example" %}
// or
{% render "Acme\Bundle\TestBundle\Controller\FirstModule\ExampleController:exampleAction" %}
I have read the Embedding Controllers documentation but no clue there how to handle Controllers that are in a sub-namespace.
Thanks.