解決済み-- エントリの下部を参照
FOSUserBundle を拡張する SonataUserBundle に慣れようとしています。
インストールは (私の知る限り) うまくいきました。ログインと登録フォームをカスタマイズしたいと思います。app/Resources のテンプレートを上書きしたところ、うまくいきました。ただし、登録フォームについては、なぜ機能するのかわかりません...
これが私の問題です:
SonataUserBundle 登録コントローラー (RegistrationFOSUser1) は、フォームをセットアップし、テンプレートとして FOSUserBundle:Registration:register.html.twig を使用してレンダリングします。
$form = $this->container->get('sonata.user.registration.form');
$formHandler = $this->container->get('sonata.user.registration.form.handler');
[...]
return $this->container->get('templating')->renderResponse('FOSUserBundle:Registration:register.html.'.$this->getEngine(), array(
'form' => $form->createView(),
));
register.html.twig には FOSUserBundle:Registration:register_content.html.twig が含まれています。
{% block fos_user_content %}
{% include "FOSUserBundle:Registration:register_content.html.twig" %}
{% endblock fos_user_content %}
register_content.html.twig には、フォームをレンダリングする小枝コードが含まれています。
ただし、実際にレンダリングされるのは SonataUserBundle:Registration:register_content.html.twig です
ここで、SonataUserBundle が FOSUserBundle をどこで、いつ、どのように置き換えるのかわかりません...
ヒントをありがとう!
わかりました、私の質問に対する解決策が symfony のクックブックに十分に文書化されていることがわかりました: http://symfony.com/doc/current/cookbook/bundles/inheritance.html
私と同じように symfony を初めて使用する人のために:
別のバンドル 'ChildBundle' の親 'ParentBundle' を定義すると、ParentBundle から関数、テンプレートなどが呼び出されるたびに、symfony は最初に ChildBundle に同じ名前のファイルがあるかどうかを調べます。
親バンドルは ChildBundle.php で定義されています。
public function getParent()
{
return 'ParentBundle';
}
親バンドルのファイルが通常の ParentBundle:path:file 表記で呼び出される限り、これは機能します。