PHP Class Dietcube\Router

Mostra file Open project: mercari/dietcube Class Usage Examples

Protected Properties

Property Type Description
$container
$dispatched_http_method
$dispatched_url
$dispatcher FastRoute\Dispatcher\GroupCountBased
$named_routes
$route_info
$routes dietcube\RouteInterface[]

Public Methods

Method Description
__construct ( Pimple\Container $container )
addRoute ( dietcube\RouteInterface $route )
dispatch ( string $http_method, string $url ) : array URL からディスパッチ対象を取得する
getDispatchedMethod ( )
getDispatchedUrl ( )
getRouteInfo ( )
init ( )
url ( string $handler, array $data = [], array $query_params = [], boolean $is_absolute = false ) : string Generate URL from route name (handler name).

Protected Methods

Method Description
buildNameIndex ( )

Method Details

__construct() public method

public __construct ( Pimple\Container $container )
$container Pimple\Container

addRoute() public method

public addRoute ( dietcube\RouteInterface $route )
$route dietcube\RouteInterface

buildNameIndex() protected method

protected buildNameIndex ( )

dispatch() public method

URL からディスパッチ対象を取得する
public dispatch ( string $http_method, string $url ) : array
$http_method string
$url string
return array

getDispatchedMethod() public method

public getDispatchedMethod ( )

getDispatchedUrl() public method

public getDispatchedUrl ( )

getRouteInfo() public method

public getRouteInfo ( )

init() public method

public init ( )

url() public method

This methods is inspired by Slim3's Router.
See also: https://github.com/slimphp/Slim/blob/3494b3625ec51c2de90d9d893767d97f876e49ff/Slim/Router.php#L162
public url ( string $handler, array $data = [], array $query_params = [], boolean $is_absolute = false ) : string
$handler string Route handler name
$data array Route URI segments replacement data
$query_params array Optional query string parameters
$is_absolute boolean Whether generate absolute url or not
return string

Property Details

$container protected_oe property

protected $container

$dispatched_http_method protected_oe property

protected $dispatched_http_method

$dispatched_url protected_oe property

protected $dispatched_url

$dispatcher protected_oe property

protected GroupCountBased,FastRoute\Dispatcher $dispatcher
return FastRoute\Dispatcher\GroupCountBased

$named_routes protected_oe property

protected $named_routes

$route_info protected_oe property

protected $route_info

$routes protected_oe property

protected RouteInterface[],dietcube $routes
return dietcube\RouteInterface[]