Ejemplo n.º 1
0
 /**
  * @param string   $name
  * @param array    $mergedParams
  * @param   string $locale
  * @return array
  */
 protected function generateRouteNamesLocalized($name, array $mergedParams, $locale)
 {
     $routeNames = array();
     if ($locale) {
         $localizedParams = $mergedParams;
         $localizedParams['_locale'] = $locale;
         $routeNames[] = RouteLoader::getRouteName($name, $localizedParams);
     }
     $routeNames[] = RouteLoader::getRouteName($name, $mergedParams);
     return $routeNames;
 }
Ejemplo n.º 2
0
 public function generateMetaTagKeyFromRelativePath($pathInfo, RouterInterface $router, $locale)
 {
     try {
         $info = $router->match($pathInfo);
     } catch (ResourceNotFoundException $e) {
         $info = false;
     } catch (MethodNotAllowedException $e) {
         $info = false;
     }
     if ($info !== false && strpos($info['_route'], RouteLoader::ROUTE_BEGIN) === 0) {
         // allready alias, get the base pathinfo
         $oldInfo = RouteLoader::getPathinfo($info['_route']);
         $oldRoute = $oldInfo['_route'];
         unset($oldInfo['_route']);
         $oldInfo[UrlGenerator::GENERATE_NORMAL_ROUTE] = true;
         $pathInfo = $router->generate($oldRoute, $oldInfo);
         $pathInfo = str_replace('/app_dev.php', '', $pathInfo);
         $pathInfo = preg_replace('!([^?]*)(\\?_locale=[^&]*)!', '$1', $pathInfo);
     }
     return $this->generateMetaTagKeyFromPathInfo($pathInfo, $locale);
 }
Ejemplo n.º 3
0
 public function canonical($pathinfo, $uri = null)
 {
     if ($uri) {
         if (!$this->keyGenerator->isAddQueryString()) {
             //remove query string
             if ($pos = strpos($uri, '?')) {
                 $uri = substr($uri, 0, $pos);
             }
         }
         //remove if rewrite not used
         $uri = str_replace('app_dev.php/', '', $uri);
         $uri = str_replace('app.php/', '', $uri);
         return $uri;
     }
     try {
         $infos = $this->router->match($pathinfo);
     } catch (ResourceNotFoundException $e) {
         $infos = false;
     } catch (MethodNotAllowedException $e) {
         $infos = false;
     }
     if ($infos === false) {
         return;
     }
     if (strpos($infos['_route'], RouteLoader::ROUTE_BEGIN) === 0) {
         $infos = RouteLoader::getPathinfo($infos['_route']);
     }
     $route = $infos['_route'];
     unset($infos['_route']);
     unset($infos['_controller']);
     return $this->router->generate($route, $infos, true);
 }