Example #1
0
 /**
  * (non-PHPdoc)
  * @see \Slince\Router\Validator\ValidatorInterface::validate()
  */
 function validate(RouteInterface $route, RequestContext $context)
 {
     $matches = [];
     $result = !$route->getCompiledRoute()->getHostRegex() || preg_match($route->getCompiledRoute()->getHostRegex(), $context->getHost(), $matches);
     if ($result) {
         $route->setReport(self::$id, $matches);
     }
     return $result;
 }
Example #2
0
 /**
  * (non-PHPdoc)
  * @see \Slince\Router\Validator\ValidatorInterface::validate()
  */
 function validate(RouteInterface $route, RequestContext $context)
 {
     $matches = [];
     $result = preg_match($route->getCompiledRoute()->getRegex(), rawurldecode($context->getParameter('path')), $matches);
     if ($result) {
         $route->setReport(self::$id, $matches);
     }
     return $result;
 }
Example #3
0
 /**
  * 获取route的pathinfo部分
  * @param RouteInterface $route
  * @return string
  */
 protected function _getRoutePath(RouteInterface $route)
 {
     return $this->_formateRouteParameters($route->getFullPath(), $this->_routeParameters, $route->getRequirements());
 }
Example #4
0
 /**
  * 处理路由action
  * 
  * @param RouteInterface $route
  * @return void
  */
 protected function _handleRouteAction(RouteInterface $route)
 {
     $routeParameters = $route->getRouteParameters();
     if (!empty($routeParameters)) {
         $action = preg_replace_callback('#\\{([a-zA-Z0-9_,]*)\\}#', function ($matches) use($routeParameters) {
             if (isset($routeParameters[$matches[1]])) {
                 return $routeParameters[$matches[1]];
             }
         }, $route->getParameter('action'));
         $route->setParameter('action', $action);
     }
 }
Example #5
0
 /**
  * (non-PHPdoc)
  * @see \Slince\Router\Validator\ValidatorInterface::validate()
  */
 function validate(RouteInterface $route, RequestContext $context)
 {
     return !$route->getMethods() || in_array($context->getMethod(), $route->getMethods());
 }