/** * Does this request match the route pattern * @param Request $request * @param boolean $matchVerb - Whether you want to match the route using the request HTTP verb * - useful for OPTIONS requests to provide route info * @param string $basePath - add a base path to the route pattern * @return boolean $result */ public function matches(Request $request, $matchVerb = true, $basePath = null) { // If we're matching the verb and we've defined them, ensure the method used is in our list of registered verbs if ($matchVerb && $this->routeMetaData->usesHttpVerbs() && !$this->methodIsInOurListOfAllowedVerbs($request->getHttpMethod())) { return false; } $patternAsRegex = $this->getMatchRegexPattern($basePath); //Cache URL params' names and values if this route matches the current HTTP request if (!preg_match('#^' . $patternAsRegex . '$#', $request->getPath(), $paramValues)) { return false; } // Process the param names and save them on the route params $this->processRouteParams($paramValues); // Check the route conditions if (!$this->routeConditionsAreValid()) { return false; } return true; }