PHP Class Phlyty\Route

Encapsulates the route, the callback to execute, and the methods it will respond to.
Datei anzeigen Open project: phly/phlyty Class Usage Examples

Protected Properties

Property Type Description
$allowedMethods array Allowed methods
$controller callable Callable assigned to this route
$methods array Methods this route responds to
$name null | string Name of this route (if any)
$route Zend\Mvc\Router\RouteInterface Route object

Public Methods

Method Description
__construct ( Zend\Mvc\Router\RouteInterface $route, callable $controller ) Constructor
allowMethod ( string $method ) : void Add an HTTP method you will allow
controller ( ) : callable Retrieve controller assigned to this route
name ( null | string $name = null ) : Route | string Retrieve and/or set the route name
respondsTo ( null | string $method = null ) : array | boolean Does this route respond to the given method?
route ( ) : Zend\Mvc\Router\RouteInterface Get the actual route interface
via ( string | array $method ) : Route Assign one or more methods this route will respond to

Method Details

__construct() public method

Accepts the router and controller.
public __construct ( Zend\Mvc\Router\RouteInterface $route, callable $controller )
$route Zend\Mvc\Router\RouteInterface
$controller callable

allowMethod() public static method

Add an HTTP method you will allow
public static allowMethod ( string $method ) : void
$method string
return void

controller() public method

Retrieve controller assigned to this route
public controller ( ) : callable
return callable

name() public method

Sets the route name if a non-empty string is provided, and then returns the Route instance to allow a fluent interface. Otherwise, returns the route name.
public name ( null | string $name = null ) : Route | string
$name null | string
return Route | string

respondsTo() public method

If no method is provided, returns array of all methods to which this route will respond.
public respondsTo ( null | string $method = null ) : array | boolean
$method null | string
return array | boolean

route() public method

Get the actual route interface
public route ( ) : Zend\Mvc\Router\RouteInterface
return Zend\Mvc\Router\RouteInterface

via() public method

Additional arguments will be used as additional methods.
public via ( string | array $method ) : Route
$method string | array
return Route

Property Details

$allowedMethods protected_oe static_oe property

Allowed methods
protected static array $allowedMethods
return array

$controller protected_oe property

Callable assigned to this route
protected callable $controller
return callable

$methods protected_oe property

Methods this route responds to
protected array $methods
return array

$name protected_oe property

Name of this route (if any)
protected null|string $name
return null | string

$route protected_oe property

Route object
protected RouteInterface,Zend\Mvc\Router $route
return Zend\Mvc\Router\RouteInterface