/** * (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; }
/** * (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; }
/** * 获取route的pathinfo部分 * @param RouteInterface $route * @return string */ protected function _getRoutePath(RouteInterface $route) { return $this->_formateRouteParameters($route->getFullPath(), $this->_routeParameters, $route->getRequirements()); }
/** * 处理路由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); } }
/** * (non-PHPdoc) * @see \Slince\Router\Validator\ValidatorInterface::validate() */ function validate(RouteInterface $route, RequestContext $context) { return !$route->getMethods() || in_array($context->getMethod(), $route->getMethods()); }