Пример #1
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);
 }
Пример #2
0
 /**
  * @param $key
  *
  * @return array An array of parameters
  */
 public function getPathInfoFromMetaTagKey($key)
 {
     $info = $this->keyGenerator->generatePathInfoFromMetaTagKey($key);
     $this->router->getContext()->setMethod('GET');
     if ($this->keyGenerator->isAddQueryString()) {
         $info = substr($info, 0, strpos($info, '?'));
         $match = $this->router->match($info);
         return $match;
     } else {
         return $this->router->match($info);
     }
 }