pushMiddlewareToGroup() public method

If the middleware is already in the group, it will not be added again.
public pushMiddlewareToGroup ( string $group, string $middleware )
$group string
$middleware string
 /**
  * Perform post-registration booting of services.
  *
  * @return void
  */
 public function boot(Router $router)
 {
     // load package routes
     if (!$this->app->routesAreCached()) {
         require __DIR__ . '/../../routes.php';
     }
     // make config file available if needed
     $this->publishes([__DIR__ . '/../../config/liveorletdie.php' => config_path('liveorletdie.php')]);
     // register package middleware
     $router->pushMiddlewareToGroup('web', \PeterColes\LiveOrLetDie\Middleware\SessionTimeout::class);
 }
 /**
  * Perform post-registration booting of services.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher  $events
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(DispatcherContract $events, Router $router)
 {
     $router->pushMiddlewareToGroup('web', ManageSiftSession::class);
     foreach ($this->listen as $event => $listeners) {
         foreach ($listeners as $listener) {
             $events->listen($event, $listener);
         }
     }
     $this->loadViewsFrom(__DIR__ . '/Views', 'sift');
     view()->composer('sift::snippet', SnippetComposer::class);
 }
 /**
  * Registers global middleware for the CMS API.
  *
  * @return $this
  */
 protected function registerCmsApiGroupMiddleware()
 {
     $this->router->middlewareGroup($this->getConfiguredApiGroupName(), []);
     foreach ($this->getGlobalApiMiddleware() as $middleware) {
         // Don't add if the middleware is already globally enabled in the kernel
         if ($this->kernel->hasMiddleware($middleware)) {
             continue;
         }
         $this->router->pushMiddlewareToGroup($this->getConfiguredApiGroupName(), $middleware);
     }
     return $this;
 }
 /**
  * Bootstrap the application events.
  *
  * @param  \Illuminate\Routing\Router $router
  *
  * @return void
  */
 public function boot(Router $router)
 {
     $resources = __DIR__ . '/../resources/';
     $this->loadViewsFrom($resources . 'views', self::PACKAGE);
     $this->loadTranslationsFrom($resources . 'lang', self::PACKAGE);
     $this->publishes([$resources . 'views' => base_path('resources/views/vendor/' . self::PACKAGE)], 'views');
     $this->publishes([$resources . 'lang' => base_path('resources/lang/vendor/' . self::PACKAGE)], 'lang');
     $this->publishes([__DIR__ . '/../public' => public_path('vendor/' . self::PACKAGE)], 'public');
     $migrationPath = __DIR__ . '/../database/migrations';
     $this->publishes([$migrationPath => base_path('database/migrations')], 'migrations');
     $config = $this->app['config']->get(self::PACKAGE . '.route', []);
     $config['namespace'] = 'Vsch\\TranslationManager';
     //$router->group($config, function ($router) {
     //    $router->get('view/{group}', 'Controller@getView');
     //    $router->controller('/', 'Controller');
     //});
     // Register Middleware so we can save our cached translations
     $router->pushMiddlewareToGroup('web', 'Vsch\\TranslationManager\\RouteAfterMiddleware');
 }
Example #5
0
 /**
  * Add a middleware to the end of a middleware group.
  * 
  * If the middleware is already in the group, it will not be added again.
  *
  * @param string $group
  * @param string $middleware
  * @return $this 
  * @static 
  */
 public static function pushMiddlewareToGroup($group, $middleware)
 {
     return \Illuminate\Routing\Router::pushMiddlewareToGroup($group, $middleware);
 }