Symfony 2 の Twig ビュー内からサブ名前空間コントローラーにあるアクションをレンダリングしようとしています。
問題は次のとおりです。 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');
}
}
これは私の見解です: 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" %}
埋め込みコントローラーのドキュメントを読みましたが、サブ名前空間にあるコントローラーを処理する方法がわかりません。
ありがとう。