Ejemplo n.º 1
0
 /**
  * Displays a form to create a new Element entity.
  *
  */
 public function newAction($id, $section_id)
 {
     $em = $this->getDoctrine()->getManager();
     $block = $em->getRepository('NovuscomCMFBundle:Block')->find($id);
     $crumbs = $this->get("apy_breadcrumb_trail");
     $crumbs->add('ACMF', 'cmf_admin_homepage');
     $crumbs->add('Инфоблоки', 'admin_block');
     $crumbs->add($block->getName(), 'admin_block_show', array('id' => $block->getId()));
     if ($section_id) {
         $section = $em->getRepository('NovuscomCMFBundle:Section')->find($section_id);
         $parentsSection = $em->getRepository('NovuscomCMFBundle:Section')->createQueryBuilder('s')->where("s.block=:block")->andWhere("s.lft<:left")->andWhere("s.rgt>:right")->andWhere("s.lvl<:level")->andWhere("s.root=:root")->setParameters(array('block' => $block, 'left' => $section->getLft(), 'right' => $section->getRgt(), 'level' => $section->getLvl(), 'root' => $section->getRoot()))->orderBy('s.lft', 'ASC')->getQuery()->getResult();
         foreach ($parentsSection as $p) {
             $crumbs->add($p->getName(), 'admin_block_show_section', array('id' => $block->getId(), 'section_id' => $p->getId()));
         }
         $crumbs->add($section->getName(), 'admin_block_show_section', array('id' => $block->getId(), 'section_id' => $section->getId()));
     }
     $entity = new Element();
     $entity->setSort(500);
     $entity->setActive(true);
     $form = $this->createCreateForm($entity);
     $crumbs->add('Создание элемента');
     return $this->render('NovuscomCMFBundle:Element:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
 }