findRoute() protected method

Find the route matching a given request.
protected findRoute ( Illuminate\Http\Request $request ) : Illuminate\Routing\Route
$request Illuminate\Http\Request
return Illuminate\Routing\Route
Example #1
0
 /**
  * Find the route matching a given request.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Themosis\Route\Route
  */
 protected function findRoute($request)
 {
     $route = parent::findRoute($request);
     // If the current route is a WordPress route
     if ($route instanceof Route && !$route->condition()) {
         global $wp, $wp_query;
         //Check if the route is not a WordPress route and warn the developer to flush the rewrite rules.
         if ($wp->matched_rule != $route->getRewriteRuleRegex()) {
             /*
              * We cannot rely on the flush_rewrite_rules() function as it's a heavy process
              * especially on a per-request manner.
              * We modify the headers status and set to 200 so it is properly handled.
              * We need to use WordPress headers functions as we only return the response
              * content on each request.
              */
             status_header(200, 'OK');
         }
         // Reset the WordPress query.
         $wp_query->init();
     }
     return $route;
 }
Example #2
0
 /**
  * Find a route either from the routers collection or the API collection.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Routing\Route
  */
 protected function findRoute($request)
 {
     if ($this->requestTargettingApi($request)) {
         list($this->requestedVersion, $this->requestedFormat) = $this->parseAcceptHeader($request);
         $this->current = $route = $this->getApiRouteCollection($this->requestedVersion)->match($request);
         return $this->substituteBindings($route);
     }
     return parent::findRoute($request);
 }
 protected function findRoute($request)
 {
     return parent::findRoute($request);
 }