class RouteGroup implements RouteInterface, HasRoutesInterface (View source)

Traits

Allow objects to have routes
Allow objects to have middleware

Methods

getRoutes()

Get registered routes

route(string[] $methods, mixed $condition, string|Closure $handler)

Create and add a new route

group(string|Closure|ConditionInterface $condition, Closure|null $routes = null)

Create and add a route group

get(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the GET and HEAD methods

post(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the POST method

put(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the PUT method

patch(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the PATCH method

delete(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the DELETE method

options(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the OPTIONS method

any(mixed $condition, string|Closure|null $handler = null)

Create and add a route for all supported methods

array
getMiddleware()

Get registered middleware

object
addMiddleware(string|Closure|MiddlewareInterface|array $middleware)

Add middleware

add(string|Closure|MiddlewareInterface|array $middleware)

Alias for addMiddleware.

ResponseInterface
executeMiddleware(array $middleware, Request $request, Closure $next)

Execute an array of middleware recursively (last in, first out)

__construct(string|Closure|ConditionInterface $condition, Closure|null $routes = null)

Constructor

boolean
isSatisfied(Request $request)

Get whether the route is satisfied.

ResponseInterface
handle(Request $request, string $view)

Get a response for the given request.

array
getArguments(Request $request)

Get arguments.

Details

RouteInterface[] getRoutes()

Get registered routes

Return Value

RouteInterface[]

RouteInterface addRoute(RouteInterface $route)

Add a route

Parameters

RouteInterface $route

Return Value

RouteInterface

RouteInterface route(string[] $methods, mixed $condition, string|Closure $handler)

Create and add a new route

Parameters

string[] $methods
mixed $condition
string|Closure $handler

Return Value

RouteInterface

RouteInterface group(string|Closure|ConditionInterface $condition, Closure|null $routes = null)

Create and add a route group

Parameters

string|Closure|ConditionInterface $condition
Closure|null $routes

Return Value

RouteInterface

RouteInterface get(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the GET and HEAD methods

Parameters

mixed $condition
string|Closure|null $handler

Return Value

RouteInterface

RouteInterface post(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the POST method

Parameters

mixed $condition
string|Closure|null $handler

Return Value

RouteInterface

RouteInterface put(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the PUT method

Parameters

mixed $condition
string|Closure|null $handler

Return Value

RouteInterface

RouteInterface patch(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the PATCH method

Parameters

mixed $condition
string|Closure|null $handler

Return Value

RouteInterface

RouteInterface delete(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the DELETE method

Parameters

mixed $condition
string|Closure|null $handler

Return Value

RouteInterface

RouteInterface options(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the OPTIONS method

Parameters

mixed $condition
string|Closure|null $handler

Return Value

RouteInterface

RouteInterface any(mixed $condition, string|Closure|null $handler = null)

Create and add a route for all supported methods

Parameters

mixed $condition
string|Closure|null $handler

Return Value

RouteInterface

array getMiddleware()

Get registered middleware

Return Value

array

object addMiddleware(string|Closure|MiddlewareInterface|array $middleware)

Add middleware

Parameters

string|Closure|MiddlewareInterface|array $middleware

Return Value

object $this

HasMiddlewareTrait add(string|Closure|MiddlewareInterface|array $middleware)

Alias for addMiddleware.

Parameters

string|Closure|MiddlewareInterface|array $middleware

Return Value

HasMiddlewareTrait $this

ResponseInterface executeMiddleware(array $middleware, Request $request, Closure $next)

Execute an array of middleware recursively (last in, first out)

Parameters

array $middleware
Request $request
Closure $next

Return Value

ResponseInterface

__construct(string|Closure|ConditionInterface $condition, Closure|null $routes = null)

Constructor

Parameters

string|Closure|ConditionInterface $condition
Closure|null $routes

boolean isSatisfied(Request $request)

Get whether the route is satisfied.

Parameters

Request $request

Return Value

boolean

ResponseInterface handle(Request $request, string $view)

Get a response for the given request.

Parameters

Request $request
string $view

Return Value

ResponseInterface

array getArguments(Request $request)

Get arguments.

Parameters

Request $request

Return Value

array