ForumBundleのベースルーティングを設定できます。ここでは、アノテーションを使用して:
/**
* Forum controller
*
* @Route("/articles/showforum/forum")
*/
class ForumController extends Controller
{...
ベースeditAction方法:
\ForumBundle\ForumController.php
public function editAction($id)
{
$this->editCustom(id);
return array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
public function editCustom(id)
{
$em = $this->getDoctrine()->getEntityManager();
$entity = $em->getRepository('ForumBundle:Topic')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Topic entity.');
}
$editForm = $this->createForm(new TopicType(), $entity);
$deleteForm = $this->createDeleteForm($id);
}
\ArticlesBundle\ForumController.php
public function editAction($id)
{
\ForumBundle\Controller\ForumController::editCustom(id);
return array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
しかし、私はまた、/写真/ showforumを持つようにしたい場合は?そして、URLの問題を解決しません(フォーラムには/ forum/newtopic、/ forum/replyなどのリンクがあります)、コンテナであるバンドルを指して、forumcontrollerにリダイレクトされます) – chris
その後、アプローチを変更する必要があります。他のバンドルに組み込むことなく使用するかのように、ForumBundleを作成してください。彼のコントローラーで必要なすべてのメソッドをPhotosBundle(ArticlesBundleと同じ)を作成するよりも、名前空間のおかげでForumBundleのメソッドを呼び出すよりも。 – dlondero
しかし、ForumBundleテンプレートのリンクはどうですか?彼らは常にForumBundleメインテンプレート(ForumBundleテンプレートを含むArtcilesBundleテンプレート)にリダイレクトします。 – chris