PHP Class ManaPHP\Mvc\Router\Group

Inheritance: extends ManaPHP\Component, implements ManaPHP\Mvc\Router\GroupInterface
Show file Open project: manaphp/manaphp Class Usage Examples

Protected Properties

Property Type Description
$_routes ManaPHP\Mvc\Router\RouteInterface[]
$_useDefaultRoutes boolean

Public Methods

Method Description
__construct ( boolean $useDefaultRoutes = true ) Group constructor.
add ( string $pattern, string | array $paths = null, string | array $httpMethod = null ) : ManaPHP\Mvc\Router\RouteInterface Adds a route to the router on any HTTP method
addDelete ( string $pattern, string | array $paths = null ) : ManaPHP\Mvc\Router\RouteInterface Adds a route to the router that only match if the HTTP method is DELETE
addGet ( string $pattern, string | array $paths = null ) : ManaPHP\Mvc\Router\RouteInterface Adds a route to the router that only match if the HTTP method is GET
addHead ( string $pattern, string | array $paths = null ) : ManaPHP\Mvc\Router\RouteInterface Adds a route to the router that only match if the HTTP method is HEAD
addOptions ( string $pattern, string | array $paths = null ) : ManaPHP\Mvc\Router\RouteInterface Add a route to the router that only match if the HTTP method is OPTIONS
addPatch ( string $pattern, string | array $paths = null ) : ManaPHP\Mvc\Router\RouteInterface Adds a route to the router that only match if the HTTP method is PATCH
addPost ( string $pattern, string | array $paths = null ) : ManaPHP\Mvc\Router\RouteInterface Adds a route to the router that only match if the HTTP method is POST
addPut ( string $pattern, string | array $paths = null ) : ManaPHP\Mvc\Router\RouteInterface Adds a route to the router that only match if the HTTP method is PUT
match ( string $uri ) : array | false

Protected Methods

Method Description
_addRoute ( string $pattern, string | array $paths = null, string $httpMethod = null ) : ManaPHP\Mvc\Router\RouteInterface Adds a route applying the common attributes

Method Details

__construct() public method

Group constructor.
public __construct ( boolean $useDefaultRoutes = true )
$useDefaultRoutes boolean

_addRoute() protected method

Adds a route applying the common attributes
protected _addRoute ( string $pattern, string | array $paths = null, string $httpMethod = null ) : ManaPHP\Mvc\Router\RouteInterface
$pattern string
$paths string | array
$httpMethod string
return ManaPHP\Mvc\Router\RouteInterface

add() public method

$router->add('/about', 'About::index');
public add ( string $pattern, string | array $paths = null, string | array $httpMethod = null ) : ManaPHP\Mvc\Router\RouteInterface
$pattern string
$paths string | array
$httpMethod string | array
return ManaPHP\Mvc\Router\RouteInterface

addDelete() public method

Adds a route to the router that only match if the HTTP method is DELETE
public addDelete ( string $pattern, string | array $paths = null ) : ManaPHP\Mvc\Router\RouteInterface
$pattern string
$paths string | array
return ManaPHP\Mvc\Router\RouteInterface

addGet() public method

Adds a route to the router that only match if the HTTP method is GET
public addGet ( string $pattern, string | array $paths = null ) : ManaPHP\Mvc\Router\RouteInterface
$pattern string
$paths string | array
return ManaPHP\Mvc\Router\RouteInterface

addHead() public method

Adds a route to the router that only match if the HTTP method is HEAD
public addHead ( string $pattern, string | array $paths = null ) : ManaPHP\Mvc\Router\RouteInterface
$pattern string
$paths string | array
return ManaPHP\Mvc\Router\RouteInterface

addOptions() public method

Add a route to the router that only match if the HTTP method is OPTIONS
public addOptions ( string $pattern, string | array $paths = null ) : ManaPHP\Mvc\Router\RouteInterface
$pattern string
$paths string | array
return ManaPHP\Mvc\Router\RouteInterface

addPatch() public method

Adds a route to the router that only match if the HTTP method is PATCH
public addPatch ( string $pattern, string | array $paths = null ) : ManaPHP\Mvc\Router\RouteInterface
$pattern string
$paths string | array
return ManaPHP\Mvc\Router\RouteInterface

addPost() public method

Adds a route to the router that only match if the HTTP method is POST
public addPost ( string $pattern, string | array $paths = null ) : ManaPHP\Mvc\Router\RouteInterface
$pattern string
$paths string | array
return ManaPHP\Mvc\Router\RouteInterface

addPut() public method

Adds a route to the router that only match if the HTTP method is PUT
public addPut ( string $pattern, string | array $paths = null ) : ManaPHP\Mvc\Router\RouteInterface
$pattern string
$paths string | array
return ManaPHP\Mvc\Router\RouteInterface

match() public method

public match ( string $uri ) : array | false
$uri string
return array | false

Property Details

$_routes protected property

protected RouteInterface[],ManaPHP\Mvc\Router $_routes
return ManaPHP\Mvc\Router\RouteInterface[]

$_useDefaultRoutes protected property

protected bool $_useDefaultRoutes
return boolean