/** * Displays a form to create a new Rub entity. * * @Secure(roles="ROLE_USER") * @access public * @author Etienne de Longeaux <*****@*****.**> */ public function newAction() { $em = $this->getDoctrine()->getManager(); $locale = $this->container->get('request')->getLocale(); $entity = new Rub(); $NoLayout = $this->container->get('request')->query->get('NoLayout'); if (!$NoLayout) { $template = "new.html.twig"; } else { $template = "new_ajax.html.twig"; } $category = $this->container->get('request')->query->get('category'); if ($category) { $entity->setCategory($em->getRepository("PiAppGedmoBundle:Category")->find($category)); } $parent_id = $this->container->get('request')->query->get('parent'); if ($parent_id) { $parent = $em->getRepository("PluginsContentBundle:Rub")->findNodeOr404($parent_id, $locale); $entity->setParent($parent); } $form = $this->createForm(new RubType($this->container, $em), $entity, array('show_legend' => false)); return $this->render("PluginsContentBundle:Rub:{$template}", array('entity' => $entity, 'form' => $form->createView(), 'NoLayout' => $NoLayout)); }
/** * Set subrub * * @param \Cmf\ContentBundle\Entity\Rub $subrub * @return BlocGeneral */ public function setSubrub(\Cmf\ContentBundle\Entity\Rub $subrub = null) { $this->subrub = $subrub; if ($subrub instanceof \Cmf\ContentBundle\Entity\Rub) { $this->mainrub = $subrub->getParent(); } return $this; }