/** * Create a new route instance. * * @param \Dingo\Api\Contract\Routing\Adapter $adapter * @param \Illuminate\Container\Container $container * @param \Illuminate\Http\Request $request * @param array|\Illuminate\Routing\Route $route * * @return void */ public function __construct(Adapter $adapter, Container $container, Request $request, $route) { $this->adapter = $adapter; $this->container = $container; list($this->uri, $this->methods, $this->action) = $this->adapter->getRouteProperties($route, $request); $this->versions = Arr::pull($this->action, 'version'); $this->conditionalRequest = Arr::pull($this->action, 'conditionalRequest', true); }
/** * Setup the route properties. * * @return void */ protected function setupRouteProperties(Request $request, $route) { list($this->uri, $this->methods, $this->action) = $this->adapter->getRouteProperties($route, $request); $this->versions = Arr::pull($this->action, 'version'); $this->conditionalRequest = Arr::pull($this->action, 'conditionalRequest', true); $this->middleware = Arr::pull($this->action, 'middleware', []); $this->throttle = Arr::pull($this->action, 'throttle'); $this->scopes = Arr::pull($this->action, 'scopes', []); $this->authenticationProviders = Arr::pull($this->action, 'providers', []); $this->rateLimit = Arr::pull($this->action, 'limit', 0); $this->rateExpiration = Arr::pull($this->action, 'expires', 0); // Now that the default route properties have been set we'll go ahead and merge // any controller properties to fully configure the route. $this->mergeControllerProperties(); // If we have a string based throttle then we'll new up an instance of the // throttle through the container. if (is_string($this->throttle)) { $this->throttle = $this->container->make($this->throttle); } }
/** * Set the raw adapter routes. * * @param array $routes * * @return void */ public function setAdapterRoutes(array $routes) { $this->adapter->setRoutes($routes); $this->container->instance('api.routes', $this->getRoutes()); }