public function nav_locale($name, $locale) { $contentsNav = $this->container->get('session')->has($name . $locale) ? $this->container->get('session')->get($name . $locale) : $this->container->get('doctrine')->getRepository('AppBundle:Nav')->findOneBy(['name' => $name, 'locale' => $locale]); if ($contentsNav) { $data = $contentsNav->getContentsNav(); $result = "<ul class='nav navbar-nav'>"; foreach ($data as $item) { if ($item->getType() == 'category') { $route = $this->routingExtenxion->getPath('app_blog_category', ['slug' => $item->getSlug()]); $result .= "<li><a href='" . $route . "'>" . $item->getName() . '</a></li>'; } if ($item->getType() == 'page') { $route = $this->routingExtenxion->getPath('app_page', ['slug' => $item->getSlug()]); $result .= "<li><a href='" . $route . "'>" . $item->getName() . '</a></li>'; } } $result .= '</ul>'; if (!$this->container->get('session')->has($name . $locale)) { $this->container->get('session')->set($name . $locale, $contentsNav); } return $result; } }