register() public method

Register a service provider with the application.
public register ( ServiceProvider | string $provider, array $options = [], boolean $force = false ) : ServiceProvider
$provider Illuminate\Support\ServiceProvider | string
$options array
$force boolean
return Illuminate\Support\ServiceProvider
Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 protected function getMiddleware(Application $app)
 {
     $pipe = new MiddlewarePipe();
     $path = parse_url($app->url(), PHP_URL_PATH);
     $errorDir = __DIR__ . '/../../error';
     if (!$app->isInstalled()) {
         $app->register('Flarum\\Install\\InstallServiceProvider');
         $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\StartSession'));
         $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\DispatchRoute', ['routes' => $app->make('flarum.install.routes')]));
         $pipe->pipe($path, new HandleErrors($errorDir, true));
     } elseif ($app->isUpToDate() && !$app->isDownForMaintenance()) {
         $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\ParseJsonBody'));
         $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\StartSession'));
         $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\RememberFromCookie'));
         $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\AuthenticateWithSession'));
         $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\SetLocale'));
         event(new ConfigureMiddleware($pipe, $path, $this));
         $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\DispatchRoute', ['routes' => $app->make('flarum.forum.routes')]));
         $pipe->pipe($path, new HandleErrors($errorDir, $app->inDebugMode()));
     } else {
         $pipe->pipe($path, function () use($errorDir) {
             return new HtmlResponse(file_get_contents($errorDir . '/503.html', 503));
         });
     }
     return $pipe;
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 protected function getMiddleware(Application $app)
 {
     $pipe = new MiddlewarePipe();
     $installed = $app->isInstalled();
     $basePath = parse_url($app->url(), PHP_URL_PATH);
     if ($installed) {
         $app->register('Flarum\\Forum\\ForumServiceProvider');
         $routes = $app->make('flarum.forum.routes');
         $pipe->pipe($basePath, $app->make('Flarum\\Http\\Middleware\\AuthenticateWithCookie'));
         $pipe->pipe($basePath, $app->make('Flarum\\Http\\Middleware\\ParseJsonBody'));
     } else {
         $app->register('Flarum\\Install\\InstallServiceProvider');
         $routes = $app->make('flarum.install.routes');
     }
     $pipe->pipe($basePath, $app->make('Flarum\\Http\\Middleware\\DispatchRoute', compact('routes')));
     $pipe->pipe(new HandleErrors(__DIR__ . '/../../error', $app->inDebugMode() || !$installed));
     return $pipe;
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 protected function getMiddleware(Application $app)
 {
     $pipe = new MiddlewarePipe();
     if ($app->isInstalled()) {
         $app->register('Flarum\\Admin\\AdminServiceProvider');
         $adminPath = parse_url($app->url('admin'), PHP_URL_PATH);
         $routes = $app->make('flarum.admin.routes');
         $pipe->pipe($adminPath, $app->make('Flarum\\Http\\Middleware\\AuthenticateWithCookie'));
         $pipe->pipe($adminPath, $app->make('Flarum\\Http\\Middleware\\ParseJsonBody'));
         $pipe->pipe($adminPath, $app->make('Flarum\\Admin\\Middleware\\RequireAdministrateAbility'));
         $pipe->pipe($adminPath, $app->make('Flarum\\Http\\Middleware\\DispatchRoute', compact('routes')));
         $pipe->pipe(new HandleErrors(__DIR__ . '/../../error', $app->inDebugMode()));
     }
     return $pipe;
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 protected function getMiddleware(Application $app)
 {
     $pipe = new MiddlewarePipe();
     if ($app->isInstalled()) {
         $app->register('Flarum\\Api\\ApiServiceProvider');
         $routes = $app->make('flarum.api.routes');
         $apiPath = parse_url($app->url('api'), PHP_URL_PATH);
         $pipe->pipe($apiPath, $app->make('Flarum\\Http\\Middleware\\AuthenticateWithCookie'));
         $pipe->pipe($apiPath, $app->make('Flarum\\Api\\Middleware\\AuthenticateWithHeader'));
         $pipe->pipe($apiPath, $app->make('Flarum\\Http\\Middleware\\ParseJsonBody'));
         $pipe->pipe($apiPath, $app->make('Flarum\\Api\\Middleware\\FakeHttpMethods'));
         $pipe->pipe($apiPath, $app->make('Flarum\\Http\\Middleware\\DispatchRoute', compact('routes')));
         $pipe->pipe($apiPath, $app->make('Flarum\\Api\\Middleware\\HandleErrors'));
     }
     return $pipe;
 }
Esempio n. 5
0
 /**
  * {@inheritdoc}
  */
 protected function getMiddleware(Application $app)
 {
     $pipe = new MiddlewarePipe();
     if ($app->isInstalled()) {
         $adminPath = parse_url($app->url('admin'), PHP_URL_PATH);
         $errorDir = __DIR__ . '/../../error';
         if ($app->isUpToDate()) {
             $pipe->pipe($adminPath, $app->make('Flarum\\Http\\Middleware\\AuthenticateWithCookie'));
             $pipe->pipe($adminPath, $app->make('Flarum\\Http\\Middleware\\ParseJsonBody'));
             $pipe->pipe($adminPath, $app->make('Flarum\\Admin\\Middleware\\RequireAdministrateAbility'));
             $pipe->pipe($adminPath, $app->make('Flarum\\Http\\Middleware\\DispatchRoute', ['routes' => $app->make('flarum.admin.routes')]));
             $pipe->pipe($adminPath, new HandleErrors($errorDir, $app->inDebugMode()));
         } else {
             $app->register('Flarum\\Update\\UpdateServiceProvider');
             $pipe->pipe($adminPath, $app->make('Flarum\\Http\\Middleware\\DispatchRoute', ['routes' => $app->make('flarum.update.routes')]));
             $pipe->pipe($adminPath, new HandleErrors($errorDir, true));
         }
     }
     return $pipe;
 }