/**
  * Render a navigation using the navigation code as the fetch criteria
  *
  * @param Request $request The Request
  * @param string  $code     The navigation code
  * @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 byCodeAction(Request $request, $code, $maxLevel = 10, $exploded = false, $template = '', $attr = array())
 {
     // Cache
     $response = new Response();
     $response->setPublic();
     $sectionLastUpdate = $this->sectionRepository->findLastUpdate();
     $sectionNavigationLastUpdate = $this->sectionNavigationRepository->findLastUpdate();
     $response->setEtag($sectionLastUpdate . $sectionNavigationLastUpdate);
     if ($response->isNotModified($request)) {
         return $response;
     }
     // Rebuild the cache
     $app_id = $this->getApp()->getId();
     $navigation = $this->navigationRepository->findOneByCodeAndApp($code, $app_id);
     if (false == $navigation) {
         throw new \Exception('Can\'t find a navigation entity using code "' . $code . '"');
     }
     $sections = $this->sectionRepository->findByNavigationAndApp($navigation->getId(), $app_id);
     $template = $template ? '_' . $template : '';
     $navigationBuilder = $this->get('unifik_system.navigation_builder');
     $navigationBuilder->setElements($sections, true, $maxLevel);
     $navigationBuilder->setSelectedElement($this->getCore()->getSection());
     $navigationBuilder->build();
     $elements = $navigationBuilder->getElements();
     return $this->render('UnifikSystemBundle:Frontend/Navigation:by_code' . $template . '.html.twig', array('code' => $code, 'sections' => $elements, 'maxLevel' => $maxLevel, 'currentSection' => $this->getSection(), 'attr' => $attr, 'exploded' => $exploded), $response);
 }