Dingo\Api\Provider\LumenServiceProvider::boot PHP Method

boot() public method

Boot the service provider.
public boot ( ) : void
return void
    public function boot()
    {
        parent::boot();
        $this->app->configure('api');
        $reflection = new ReflectionClass($this->app);
        $this->app[Request::class]->mergeMiddlewares($this->gatherAppMiddleware($reflection));
        $this->addRequestMiddlewareToBeginning($reflection);
        // Because Lumen sets the route resolver at a very weird point we're going to
        // have to use reflection whenever the request instance is rebound to
        // set the route resolver to get the current route.
        $this->app->rebinding(IlluminateRequest::class, function ($app, $request) {
            $request->setRouteResolver(function () use($app) {
                $reflection = new ReflectionClass($app);
                $property = $reflection->getProperty('currentRoute');
                $property->setAccessible(true);
                return $property->getValue($app);
            });
        });
        $this->app->routeMiddleware(['api.auth' => Auth::class, 'api.throttle' => RateLimit::class, 'api.controllers' => PrepareController::class]);
    }