예제 #1
0
 /**
  * Deletes a Section entity.
  *
  * @param Request $request
  * @param integer $id      The ID of the Section to delete
  *
  * @return RedirectResponse
  */
 public function deleteAction(Request $request, $id)
 {
     $section = $this->sectionRepository->find($id);
     $this->deleteEntity($section);
     $this->get('unifik_system.router_invalidator')->invalidate();
     return $this->redirect($this->generateUrl('unifik_system_backend_section'));
 }
 /**
  * Render a navigation displaying children starting from a section
  *
  * @param Request $request The Request
  * @param mixed   $section  The section entity or section id to start from
  * @param int     $maxLevel The level maximum limit, this is the rendering loop level limit, not the section entity level
  * @param bool    $exploded When false only the currently selected tree path is displayed
  * @param string  $template Force the template code to use
  * @param array   $attr     Array of attribure to add to the element (Ex. id="aaa" class="bbb")
  *
  * @return Response
  *
  * @throws \Exception
  */
 public function fromSectionAction(Request $request, $section, $maxLevel = 10, $exploded = false, $template = '', $attr = [])
 {
     // Cache
     $response = new Response();
     $response->setPublic();
     $response->setEtag($this->sectionRepository->findLastUpdate());
     if ($response->isNotModified($request)) {
         return $response;
     }
     // Rebuild the cache
     if (is_numeric($section)) {
         $section = $this->sectionRepository->findOneWithChildren($section);
     }
     $elements = [];
     if ($parents = $section->getParents()) {
         $elements = $parents[1]->getChildren();
     } elseif (count($section->getChildren())) {
         $elements = $section->getChildren();
     }
     $template = $template ? '_' . $template : '';
     $navigationBuilder = $this->get('unifik_system.navigation_builder');
     $navigationBuilder->setElements($elements, true, $maxLevel);
     $navigationBuilder->setSelectedElement($this->getCore()->getSection());
     $navigationBuilder->build();
     $elements = $navigationBuilder->getElements();
     return $this->render('UnifikSystemBundle:Frontend/Navigation:from_section' . $template . '.html.twig', array('sections' => $elements, 'maxLevel' => $maxLevel, 'currentSection' => $this->getSection(), 'attr' => $attr, 'exploded' => $exploded), $response);
 }
 /**
  * Section Bar Action
  *
  * @return Response
  */
 public function sectionBarAction()
 {
     $sectionCurrent = $this->getSection();
     if (false == $sectionCurrent) {
         $sectionCurrent = new Section();
     }
     $sections = $this->sectionRepository->findByAppJoinChildren($this->getApp());
     // Cleanup of level 1 sections
     foreach ($sections as $key => $section) {
         if ($section->getParent()) {
             unset($sections[$key]);
         }
     }
     $navigationBuilder = $this->get('unifik_system.navigation_builder');
     $navigationBuilder->setElements($sections);
     $navigationBuilder->setSelectedElement($sectionCurrent);
     $navigationBuilder->build();
     $sections = $navigationBuilder->getElements();
     $sections = $this->get('unifik_system.section_filter')->filterSections($sections);
     return $this->render('UnifikSystemBundle:Backend/Navigation:section_bar.html.twig', array('sections' => $sections, 'sectionCurrent' => $sectionCurrent, 'managedApp' => $this->getApp()));
 }
예제 #4
0
 /**
  * Deletes a Root Section entity.
  *
  * @param Request $request
  * @param integer $id      The ID of the Section to delete
  *
  * @return RedirectResponse
  */
 public function deleteAction(Request $request, $id)
 {
     $section = $this->sectionRepository->find($id);
     $this->deleteEntity($section);
     return $this->redirect($this->generateUrl('unifik_system_backend_section_root', array('appSlug' => $this->getApp()->getSlug())));
 }