class MainRouter extends Router implements RouteBuilderInterface, DispatcherAwareInterface, DispatcherInterface (View source)

The Router class.

Traits

DispatcherAwareTrait
The RouteBuilderTrait class.

Methods

string
route(string $route, array $queries = array(), string $type = MainRouter::TYPE_PATH)

build

string
fullRoute(string $route, array $queries = array())

fullRoute

string
rawRoute(string $route, array $queries = array())

rawRoute

string
escape(string $text)

escape

__construct(MatcherInterface $matcher, UriData $uri, DispatcherInterface $dispatcher)

Class init.

string
build(string $route, array $queries = array(), string $type = MainRouter::TYPE_RAW)

build

Route
match(string $rawRoute, string $method = 'GET', array $options = array())

match

string
addBase(string $uri, string $path = 'path')

addBase

string
fetchControllerSuffix(string $method = 'GET', array $customSuffix = array())

Get the controller class suffix string.

Route
addRouteByConfig(string $name, array $route, string|AbstractPackage $package = null, string $prefix = '/')

addRouteByConfig

static array
loadRoutingFiles(array $files)

loadRoutingFromFiles

static array
loadRoutingFile(array $file)

loadRoutingFromFile

registerRawRouting(array $routes, PackageResolver $resolver)

loadRawRouting

addRouteByConfigs(array $routes, string|AbstractPackage $package = null)

addRouteByConfigs

addRouteFromFile(string $file, string|AbstractPackage $package = null)

addRouteByFile

addRouteFromFiles(array $files, string|AbstractPackage $package = null)

addRouteByFile

setHttpMethodSuffix(string $method, string $suffix)

Set a controller class suffix for a given HTTP method.

array
getSuffixMap()

Method to get property SuffixMap

setSuffixMap(array $suffixMap)

Method to set property suffixMap

string
getController()

Method to get property Controller

UriData
getUri()

Method to get property Uri

setUri(UriData $uri)

Method to set property uri

Route
getMatched()

Method to get property Matched

setMatched(Route $matched)

Method to set property matched

addListener(object|Closure $listener, array|integer $priorities = array())

Add a listener to this dispatcher, only if not already registered to these events.

listen(string $event, callable $callable, int $priority = ListenerPriority::NORMAL)

on

Details

at line line 186
string route(string $route, array $queries = array(), string $type = MainRouter::TYPE_PATH)

build

Parameters

string $route
array $queries
string $type

Return Value

string

Exceptions

OutOfRangeException

string fullRoute(string $route, array $queries = array())

fullRoute

Parameters

string $route
array $queries

Return Value

string

string rawRoute(string $route, array $queries = array())

rawRoute

Parameters

string $route
array $queries

Return Value

string

string escape(string $text)

escape

Parameters

string $text

Return Value

string

at line line 90
__construct(MatcherInterface $matcher, UriData $uri, DispatcherInterface $dispatcher)

Class init.

Parameters

MatcherInterface $matcher
UriData $uri
DispatcherInterface $dispatcher

at line line 110
string build(string $route, array $queries = array(), string $type = MainRouter::TYPE_RAW)

build

Parameters

string $route
array $queries
string $type

Return Value

string

Exceptions

LogicException

at line line 221
Route match(string $rawRoute, string $method = 'GET', array $options = array())

match

Parameters

string $rawRoute
string $method
array $options

Return Value

Route

Exceptions

RouteNotFoundException
LogicException

at line line 284
string addBase(string $uri, string $path = 'path')

addBase

Parameters

string $uri
string $path

Return Value

string

at line line 305
string fetchControllerSuffix(string $method = 'GET', array $customSuffix = array())

Get the controller class suffix string.

Parameters

string $method
array $customSuffix

Return Value

string

Exceptions

RouteNotFoundException

at line line 360
Route addRouteByConfig(string $name, array $route, string|AbstractPackage $package = null, string $prefix = '/')

addRouteByConfig

Parameters

string $name
array $route
string|AbstractPackage $package
string $prefix

Return Value

Route

at line line 413
static array loadRoutingFiles(array $files)

loadRoutingFromFiles

Parameters

array $files

Return Value

array

at line line 437
static array loadRoutingFile(array $file)

loadRoutingFromFile

Parameters

array $file

Return Value

array

at line line 450
MainRouter registerRawRouting(array $routes, PackageResolver $resolver)

loadRawRouting

Parameters

array $routes
PackageResolver $resolver

Return Value

MainRouter

at line line 489
MainRouter addRouteByConfigs(array $routes, string|AbstractPackage $package = null)

addRouteByConfigs

Parameters

array $routes
string|AbstractPackage $package

Return Value

MainRouter

at line line 507
MainRouter addRouteFromFile(string $file, string|AbstractPackage $package = null)

addRouteByFile

Parameters

string $file
string|AbstractPackage $package

Return Value

MainRouter

at line line 522
MainRouter addRouteFromFiles(array $files, string|AbstractPackage $package = null)

addRouteByFile

Parameters

array $files
string|AbstractPackage $package

Return Value

MainRouter

at line line 540
MainRouter setHttpMethodSuffix(string $method, string $suffix)

Set a controller class suffix for a given HTTP method.

Parameters

string $method The HTTP method for which to set the class suffix.
string $suffix The class suffix to use when fetching the controller name for a given request.

Return Value

MainRouter Returns itself to support chaining.

at line line 552
array getSuffixMap()

Method to get property SuffixMap

Return Value

array

at line line 564
MainRouter setSuffixMap(array $suffixMap)

Method to set property suffixMap

Parameters

array $suffixMap

Return Value

MainRouter Return self to support chaining.

at line line 576
string getController()

Method to get property Controller

Return Value

string

at line line 586
UriData getUri()

Method to get property Uri

Return Value

UriData

at line line 603
MainRouter setUri(UriData $uri)

Method to set property uri

Parameters

UriData $uri

Return Value

MainRouter Return self to support chaining.

at line line 629
Route getMatched()

Method to get property Matched

Return Value

Route

at line line 641
MainRouter setMatched(Route $matched)

Method to set property matched

Parameters

Route $matched

Return Value

MainRouter Return self to support chaining.

at line line 663
MainRouter addListener(object|Closure $listener, array|integer $priorities = array())

Add a listener to this dispatcher, only if not already registered to these events.

If no events are specified, it will be registered to all events matching it's methods name. In the case of a closure, you must specify at least one event name.

Parameters

object|Closure $listener The listener
array|integer $priorities An associative array of event names as keys and the corresponding listener priority as values.

Return Value

MainRouter

Exceptions

InvalidArgumentException

at line line 679
MainRouter listen(string $event, callable $callable, int $priority = ListenerPriority::NORMAL)

on

Parameters

string $event
callable $callable
int $priority

Return Value

MainRouter