com\setasign\SetaFramework\Router\Route

Multi Class Route Multi

File: /SetaFramework/src/Router/Route/Multi.php

Class hierarchy

Implements

Summary

Constants

DEFAULT_PRIORITY


Properties

$logger

protected ?\Psr\Log\LoggerInterface \com\setasign\SetaFramework\Router\AbstractRouter::$logger

$mainRoute

protected Multi::$mainRoute

Methods

__construct()

public Multi::__construct (
RouteInterface $mainRoute
)

This route can have own sub-routes which will only checked if the mainRoute is matching.

Parameters
$mainRoute : RouteInterface

Contains the main route of this

appendRoute()

Append a route after the route $after.

If $after is an empty string than the added route will be the last route.

The name of the route need to be unique.

Parameters
$name : string

Name of the new route

$route : RouteInterface

Route

$after : string

Append this route after the route with this name

$priority : int
 
Exceptions

Throws \com\setasign\SetaFramework\Router\RouteException

getRoute()

Returns a route

Parameters
$routeName : string
 
Exceptions

Throws \InvalidArgumentException

getRoutes()

Returns all routes in the correct order

Exceptions

Throws \com\setasign\SetaFramework\Router\RouteException

match()

public Multi::match (
\Psr\Http\Message\RequestInterface $request
): ?array

Checks whether this route matches to the request

Parameters
$request : \Psr\Http\Message\RequestInterface
 
Return Values

Returns associative array(without any numeric key) with values or NULL if the route not match

prependRoute()

Prepend a route before the route $before.

If $before is an empty string than the added route will be the first route.

The name of the route need to be unique.

Parameters
$name : string

Name of the new route

$route : RouteInterface

Route

$before : string

Prepend this route before the route with this name

$priority : int
 
Exceptions

Throws \com\setasign\SetaFramework\Router\RouteException

process()

public \com\setasign\SetaFramework\Router\AbstractRouter::process (
\Psr\Http\Message\RequestInterface $request
): array

Calls the match-method of all routes in the correct order and break if one route is matching

The result of a matching route will be merged with the default values of this and will be returned

Parameters
$request : \Psr\Http\Message\RequestInterface
 
Exceptions

Throws \com\setasign\SetaFramework\Router\RouteException

resolveAppendingRoutes()

Parameters
$name : string
 

resolvePrependingRoutes()

Parameters
$name : string
 

setDefaultValue()

public Multi::setDefaultValue (
string $key,
mixed $value
): void

Proxy method for mainRoute->setDefaultValue

Parameters
$key : string

The key shouldn't be a natural number

$value : mixed
 
See

setDefaultValues()

public Multi::setDefaultValues (
array<string, mixed> $defaultValues
): void

Proxy method for mainRoute->setDefaultValues

Parameters
$defaultValues : array<string, mixed>

The keys of this array shouldn't be natural numbers

See

setLogger()

public \com\setasign\SetaFramework\Router\AbstractRouter::setLogger (
\Psr\Log\LoggerInterface $logger
): void

Sets a logger instance on the object.

Parameters
$logger : \Psr\Log\LoggerInterface