final class Yaf_Route_Regex extends Yaf_Router implements Yaf_Route_Interface (View source)

Yaf_Route_Regex is the most flexible route among the Yaf built-in routes.

Properties

protected Yaf_Route_Interface[] $_routes from  Yaf_Router
protected string $_current from  Yaf_Router
protected string $_route
protected array $_default
protected array $_maps
protected array $_verify
protected string $_reverse

Methods

__construct(string $match, array $route, array|null $map = null, array|null $verify = null, string $reverse = null)

No description

Yaf_Router|false
addRoute(string $name, Yaf_Route_Interface $route)

by default, Yaf_Router using a Yaf_Route_Static as its default route. you can add new routes into router's route stack by calling this method.


the newer route will be called before the older(route stack), and if the newer router return TRUE, the router process will be end. otherwise, the older one will be called.

Yaf_Router|false
addConfig(Yaf_Config_Abstract $config)

Add routes defined by configs into Yaf_Router's route stack

bool
route(Yaf_Request_Abstract $request)

Route a incoming request.

getRoute(string $name)

Retrieve a route by name, see also Yaf_Router::getCurrentRoute()

getRoutes()

No description

string
getCurrentRoute()

Get the name of the route which is effective in the route process.


Note:

You should call this method after the route process finished, since before that, this method will always return NULL.

bool
assemble(array $info, array|null $query = null)

Yaf_Route_Regex::assemble() - Assemble a url

bool
match(string $uri)

No description

Details

__construct(string $match, array $route, array|null $map = null, array|null $verify = null, string $reverse = null)

No description

Parameters

string $match

A complete Regex pattern, will be used to match a request uri, if doesn't matched, Yaf_Route_Regex will return FALSE.

array $route

When the match pattern matches the request uri, Yaf_Route_Regex will use this to decide which m/c/a to routed.


either of m/c/a in this array is optional, if you don't assign a specific value, it will be routed to default.

array|null $map

A array to assign name to the captures in the match result.

array|null $verify
string $reverse

Exceptions

Yaf_Exception_TypeError

Yaf_Router|false addRoute(string $name, Yaf_Route_Interface $route)

by default, Yaf_Router using a Yaf_Route_Static as its default route. you can add new routes into router's route stack by calling this method.


the newer route will be called before the older(route stack), and if the newer router return TRUE, the router process will be end. otherwise, the older one will be called.

Parameters

string $name
Yaf_Route_Interface $route

Return Value

Yaf_Router|false

return FALSE on failure

Yaf_Router|false addConfig(Yaf_Config_Abstract $config)

Add routes defined by configs into Yaf_Router's route stack

Parameters

Yaf_Config_Abstract $config

Return Value

Yaf_Router|false

return FALSE on failure

bool route(Yaf_Request_Abstract $request)

Route a incoming request.

Parameters

Yaf_Request_Abstract $request

Return Value

bool

Yaf_Route_Interface getRoute(string $name)

Retrieve a route by name, see also Yaf_Router::getCurrentRoute()

Parameters

string $name

Return Value

Yaf_Route_Interface

Yaf_Route_Interface[] getRoutes()

No description

Return Value

Yaf_Route_Interface[]

string getCurrentRoute()

Get the name of the route which is effective in the route process.


Note:

You should call this method after the route process finished, since before that, this method will always return NULL.

Return Value

string

the name of the effective route.

bool assemble(array $info, array|null $query = null)

Yaf_Route_Regex::assemble() - Assemble a url

Parameters

array $info
array|null $query

Return Value

bool

bool match(string $uri)

No description

Parameters

string $uri

Return Value

bool