PHP Class Orno\Route\RouteCollection

Inheritance: extends FastRoute\RouteCollector, implements Orno\Route\RouteStrategyInterface, use trait Orno\Route\RouteStrategyTrait
Show file Open project: orno/route Class Usage Examples

Protected Properties

Property Type Description
$config Orno\Config\Repository | array
$container Orno\Di\ContainerInterface
$routes array

Public Methods

Method Description
__construct ( Orno\Di\ContainerInterface $container = null, Orno\Config\Repository $config = null, FastRoute\RouteParser $parser = null, FastRoute\DataGenerator $generator = null ) Constructor
addRoute ( string $method, string $route, string | Closure $handler, integer $strategy = self::REQUEST_RESPONSE_STRATEGY ) : RouteCollection Add a route to the collection
delete ( string $route, string | Closure $handler, integer $strategy = self::REQUEST_RESPONSE_STRATEGY ) : RouteCollection Add a route that responds to DELETE HTTP method
get ( string $route, string | Closure $handler, integer $strategy = self::REQUEST_RESPONSE_STRATEGY ) : RouteCollection Add a route that responds to GET HTTP method
getDispatcher ( ) : Dispatcher Builds a dispatcher based on the routes attached to this collection
head ( string $route, string | Closure $handler, integer $strategy = self::REQUEST_RESPONSE_STRATEGY ) : RouteCollection Add a route that responds to HEAD HTTP method
options ( string $route, string | Closure $handler, integer $strategy = self::REQUEST_RESPONSE_STRATEGY ) : RouteCollection Add a route that responds to OPTIONS HTTP method
patch ( string $route, string | Closure $handler, integer $strategy = self::REQUEST_RESPONSE_STRATEGY ) : RouteCollection Add a route that responds to PATCH HTTP method
post ( string $route, string | Closure $handler, integer $strategy = self::REQUEST_RESPONSE_STRATEGY ) : RouteCollection Add a route that responds to POST HTTP method
put ( string $route, string | Closure $handler, integer $strategy = self::REQUEST_RESPONSE_STRATEGY ) : RouteCollection Add a route that responds to PUT HTTP method

Protected Methods

Method Description
parseRouteString ( string $route ) : string Convenience method to convert pre-defined key words in to regex strings

Method Details

__construct() public method

Constructor
public __construct ( Orno\Di\ContainerInterface $container = null, Orno\Config\Repository $config = null, FastRoute\RouteParser $parser = null, FastRoute\DataGenerator $generator = null )
$container Orno\Di\ContainerInterface
$config Orno\Config\Repository
$parser FastRoute\RouteParser
$generator FastRoute\DataGenerator

addRoute() public method

Add a route to the collection
public addRoute ( string $method, string $route, string | Closure $handler, integer $strategy = self::REQUEST_RESPONSE_STRATEGY ) : RouteCollection
$method string
$route string
$handler string | Closure
$strategy integer
return RouteCollection

delete() public method

Add a route that responds to DELETE HTTP method
public delete ( string $route, string | Closure $handler, integer $strategy = self::REQUEST_RESPONSE_STRATEGY ) : RouteCollection
$route string
$handler string | Closure
$strategy integer
return RouteCollection

get() public method

Add a route that responds to GET HTTP method
public get ( string $route, string | Closure $handler, integer $strategy = self::REQUEST_RESPONSE_STRATEGY ) : RouteCollection
$route string
$handler string | Closure
$strategy integer
return RouteCollection

getDispatcher() public method

Builds a dispatcher based on the routes attached to this collection
public getDispatcher ( ) : Dispatcher
return Dispatcher

head() public method

Add a route that responds to HEAD HTTP method
public head ( string $route, string | Closure $handler, integer $strategy = self::REQUEST_RESPONSE_STRATEGY ) : RouteCollection
$route string
$handler string | Closure
$strategy integer
return RouteCollection

options() public method

Add a route that responds to OPTIONS HTTP method
public options ( string $route, string | Closure $handler, integer $strategy = self::REQUEST_RESPONSE_STRATEGY ) : RouteCollection
$route string
$handler string | Closure
$strategy integer
return RouteCollection

parseRouteString() protected method

Convenience method to convert pre-defined key words in to regex strings
protected parseRouteString ( string $route ) : string
$route string
return string

patch() public method

Add a route that responds to PATCH HTTP method
public patch ( string $route, string | Closure $handler, integer $strategy = self::REQUEST_RESPONSE_STRATEGY ) : RouteCollection
$route string
$handler string | Closure
$strategy integer
return RouteCollection

post() public method

Add a route that responds to POST HTTP method
public post ( string $route, string | Closure $handler, integer $strategy = self::REQUEST_RESPONSE_STRATEGY ) : RouteCollection
$route string
$handler string | Closure
$strategy integer
return RouteCollection

put() public method

Add a route that responds to PUT HTTP method
public put ( string $route, string | Closure $handler, integer $strategy = self::REQUEST_RESPONSE_STRATEGY ) : RouteCollection
$route string
$handler string | Closure
$strategy integer
return RouteCollection

Property Details

$config protected property

protected Repository,Orno\Config|array $config
return Orno\Config\Repository | array

$container protected property

protected ContainerInterface,Orno\Di $container
return Orno\Di\ContainerInterface

$routes protected property

protected array $routes
return array