Reputation: 694
I have problem with that concept: I want to have bundle forum (display comments, adding new, etc.), but I want to display it in another bundle (lets say url: /articles/showforum). I can include forum inside /articles/showforum, but links will be the old ones (e.g. to show form to add new topic: /forum/newtopic). I want sth like /articles/showforum/forum/newtopic - is there such a tool in Symfony 2 to achieve this?
Upvotes: 2
Views: 1693
Reputation: 2597
You can set base routing for your ForumBundle. Here using annotations:
/**
* Forum controller
*
* @Route("/articles/showforum/forum")
*/
class ForumController extends Controller
{...
A base editAction method:
\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(),
);
}
Upvotes: 2