PHP Class SebastiaanLuca\Router\ExtendedRouter

An extension to the application's router to provide extra functionality.
Inheritance: extends Illuminate\Routing\Router, implements Illuminate\Contracts\Routing\Registrar
Show file Open project: sebastiaanluca/laravel-router

Protected Properties

Property Type Description
$isBootstrapped boolean Indicates if all the service providers have been loaded.
$routeMiddleware array The registered middleware for named routes.

Public Methods

Method Description
__construct ( Illuminate\Contracts\Events\Dispatcher $events, Illuminate\Container\Container $container = null ) Create a new Router instance.
linkNamedRouteMiddleware ( ) Link all registered middleware to the corresponding routes.
registerNamedRouteMiddleware ( string | array $routes, string | array $middleware ) Register middleware to add to a named route.

Protected Methods

Method Description
addMiddlewareToRoute ( string $name, array $middleware ) Add middleware to a named route.

Method Details

__construct() public method

Create a new Router instance.
public __construct ( Illuminate\Contracts\Events\Dispatcher $events, Illuminate\Container\Container $container = null )
$events Illuminate\Contracts\Events\Dispatcher
$container Illuminate\Container\Container

addMiddlewareToRoute() protected method

Optionally handles wildcard named routes.
protected addMiddlewareToRoute ( string $name, array $middleware )
$name string
$middleware array

linkNamedRouteMiddleware() public method

The call to this method is delayed until all service providers have been registered and booted. This way all routes are defined before we try to apply any middleware.

registerNamedRouteMiddleware() public method

AKA Route::when() but for middleware. Use an asterisk (*) for wildcard entries. E.g. users.* filters all user routes.
public registerNamedRouteMiddleware ( string | array $routes, string | array $middleware )
$routes string | array
$middleware string | array

Property Details

$isBootstrapped protected property

Indicates if all the service providers have been loaded.
protected bool $isBootstrapped
return boolean

$routeMiddleware protected property

The registered middleware for named routes.
protected array $routeMiddleware
return array