class Route implements RouteInterface (View source)

Represent a route

Traits

Allow objects to have middleware

Methods

array
getMiddleware()

Get registered middleware

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[] $methods, mixed $condition, string|Closure $handler)

Constructor.

string[]
getMethods()

Get allowed methods.

getCondition()

Get condition.

getHandler()

Get handler.

callable|null
getQueryFilter()

Get the main WordPress query vars filter, if any.

void
setQueryFilter(callable|null $query_filter)

Set the main WordPress query vars filter and add it to the appropriate WordPress action.

void
addQueryFilter()

Add the query filter to the appropriate WordPress action.

void
removeQueryFilter()

Remove the query filter from the appropriate WordPress action.

array
applyQueryFilter(array $query_vars)

Apply the query filter, if any.

query(callable $query_filter)

Set the main WordPress query vars filter.

boolean
isSatisfied(Request $request)

Get whether the route is satisfied.

array
getArguments(Request $request)

Get arguments.

ResponseInterface
handle(Request $request, string $view)

Get a response for the given request.

Details

array getMiddleware()

Get registered middleware

Return Value

array

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

Add middleware.

Accepts: a class name, an instance of a class, a Closure or an array of any of the previous

Parameters

string|Closure|MiddlewareInterface|array $middleware

Return Value

HasMiddlewareTrait $this

Exceptions

Exception

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[] $methods, mixed $condition, string|Closure $handler)

Constructor.

Parameters

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

Exceptions

Exception

string[] getMethods()

Get allowed methods.

Return Value

string[]

ConditionInterface getCondition()

Get condition.

Return Value

ConditionInterface

RouteHandler getHandler()

Get handler.

Return Value

RouteHandler

callable|null getQueryFilter()

Get the main WordPress query vars filter, if any.

Return Value

callable|null

void setQueryFilter(callable|null $query_filter)

Set the main WordPress query vars filter and add it to the appropriate WordPress action.

Parameters

callable|null $query_filter

Return Value

void

void addQueryFilter()

Add the query filter to the appropriate WordPress action.

Return Value

void

void removeQueryFilter()

Remove the query filter from the appropriate WordPress action.

Return Value

void

array applyQueryFilter(array $query_vars)

Apply the query filter, if any.

Parameters

array $query_vars mixed> $query_vars

Return Value

array mixed>

Exceptions

Exception

Route query(callable $query_filter)

Set the main WordPress query vars filter.

Alias of ::setQueryFilter()

Parameters

callable $query_filter

Return Value

Route $this

boolean isSatisfied(Request $request)

Get whether the route is satisfied.

Parameters

Request $request

Return Value

boolean

array getArguments(Request $request)

Get arguments.

Parameters

Request $request

Return Value

array

ResponseInterface handle(Request $request, string $view)

Get a response for the given request.

Parameters

Request $request
string $view

Return Value

ResponseInterface