コード例 #1
0
 public function getAppRoute($route_name, $app_id = null)
 {
     if (!$this->mappingRepository) {
         $this->mappingRepository = $this->doctrine->getManager()->getRepository('UnifikSystemBundle:Mapping');
     }
     $mapping = $this->mappingRepository->findOneBy(array('app' => $app_id ? $app_id : $this->systemCore->getApplicationCore()->getApp()->getId(), 'type' => 'route', 'target' => $route_name), array('section' => 'ASC'));
     if ($mapping) {
         // Faut checker toutes les routes, à cause du mapping alias
         $routes = $this->router->getRouteCollection()->all();
         foreach ($routes as $name => $route) {
             if ($defaults = $route->getDefaults()) {
                 if (array_key_exists('_unifikRequest', $defaults) && array_key_exists('mappedRouteName', $defaults['_unifikRequest'])) {
                     $real_name = preg_replace('/^[aA-zZ]{2}__[A-Z]{2}__/', '', $defaults['_unifikRequest']['mappedRouteName']);
                     // On a trouvé la bonne route
                     if ($real_name == $route_name) {
                         return preg_replace('/^[aA-zZ]{2}__[A-Z]{2}__/', '', $name);
                     }
                 }
             }
         }
         // On a rien trouvé... on retourne la route "par défaut" de la section
         return 'section_id_' . $mapping->getSection()->getId();
     }
     // Aucun mapping... on fallback sur la premiere route disponible (?)
     $mapping = $this->mappingRepository->findOneBy(array('type' => 'route', 'target' => $route_name), array('section' => 'ASC'));
     if ($mapping) {
         return 'section_id_' . $mapping->getSection()->getId();
     }
     // Rien de concluant
     return null;
 }
コード例 #2
0
 /**
  * This render the modules that are associated with the current section
  *
  * @return Response
  */
 public function sectionModuleBarAction()
 {
     if (false == $this->getSection()) {
         return new Response();
     }
     $mappings = $this->mappingRepository->findBy(array('section' => $this->getSection(), 'navigation' => NavigationRepository::SECTION_MODULE_BAR_ID), array('ordering' => 'ASC'));
     return $this->render('UnifikSystemBundle:Backend/Navigation:section_module_bar.html.twig', array('mappings' => $mappings));
 }