Neos\Flow\Mvc\Routing\Router::route PHP Метод

route() публичный Метод

Returns the matchResults of the matching route or NULL if no matching route could be found.
public route ( Request $httpRequest ) : array
$httpRequest Neos\Flow\Http\Request The web request to be analyzed. Will be modified by the router.
Результат array The results of the matching route or NULL if no route matched
    public function route(Request $httpRequest)
    {
        $cachedMatchResults = $this->routerCachingService->getCachedMatchResults($httpRequest);
        if ($cachedMatchResults !== false) {
            return $cachedMatchResults;
        }
        $this->lastMatchedRoute = null;
        $this->createRoutesFromConfiguration();
        /** @var $route Route */
        foreach ($this->routes as $route) {
            if ($route->matches($httpRequest) === true) {
                $this->lastMatchedRoute = $route;
                $matchResults = $route->getMatchResults();
                if ($matchResults !== null) {
                    $this->routerCachingService->storeMatchResults($httpRequest, $matchResults);
                }
                $this->systemLogger->log(sprintf('Router route(): Route "%s" matched the path "%s".', $route->getName(), $httpRequest->getRelativePath()), LOG_DEBUG);
                return $matchResults;
            }
        }
        $this->systemLogger->log(sprintf('Router route(): No route matched the route path "%s".', $httpRequest->getRelativePath()), LOG_NOTICE);
        return null;
    }

Usage Example

 /**
  * @param Request $httpRequest
  * @return ActionRequest
  */
 protected function route(Request $httpRequest)
 {
     $actionRequest = new ActionRequest($httpRequest);
     $matchResults = $this->router->route($httpRequest);
     if ($matchResults !== null) {
         $requestArguments = $actionRequest->getArguments();
         $mergedArguments = Arrays::arrayMergeRecursiveOverrule($requestArguments, $matchResults);
         $actionRequest->setArguments($mergedArguments);
     }
     return $actionRequest;
 }
All Usage Examples Of Neos\Flow\Mvc\Routing\Router::route