Пример #1
0
 /**
  * 获取route的pathinfo部分
  * @param RouteInterface $route
  * @param array $parameters
  * @return string
  */
 protected function getRoutePath(RouteInterface $route, $parameters)
 {
     return $this->formatRouteHostOrPath($route->getPath(), $parameters, $route->getRequirements());
 }
Пример #2
0
 /**
  * 匹配path
  * @param string $path
  * @param RouteInterface $route
  * @return boolean
  */
 protected function matchPath($path, RouteInterface $route)
 {
     //如果没有path则直接忽略
     if (empty($route->getPath())) {
         return true;
     }
     if (preg_match($route->compile()->getPathRegex(), rawurldecode($path), $matches)) {
         $routeParameters = array_intersect_key($matches, array_flip($route->getVariables()));
         $route->setParameter('_pathMatches', $routeParameters);
         return true;
     }
     return false;
 }