SlaxWeb Framework
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SlaxWeb\Router\Container Class Reference

Public Member Functions

 __construct (\Psr\Log\LoggerInterface $logger)
 
 add (Route $route)
 
 defaultRoute ()
 
 get404Route ()
 
 getAll ()
 
 next ()
 
 prev ()
 

Protected Member Functions

 iterateRoutes (string $function)
 

Protected Attributes

 $routes = []
 
 $currentRoute = null
 
 $logger = null
 
 $defaultRoute = null
 
 $e404Route = null
 

Constructor & Destructor Documentation

SlaxWeb\Router\Container::__construct ( \Psr\Log\LoggerInterface  $logger)

Class constructor

Store the retrieved logger that implements the to the class protected property.

Parameters
\Psr\Log\LoggerInterface$loggerLogger object

Member Function Documentation

SlaxWeb\Router\Container::add ( Route  $route)

Add Route definition

Add the retrieved Route to the internal Routes container array. If the retrieved Route is not complete, throw the 'RouteIncompleteException'.

Parameters
\SlaxWeb\Router\Route$routeRoute definition object
Returns
self
SlaxWeb\Router\Container::defaultRoute ( )

Get default route

Returns the default route if set. If the default Route is not set, it returns null.

Returns
|null
SlaxWeb\Router\Container::get404Route ( )

Get the 404 route

Returns the 404 route if set. If the 404 Route is not set, it returns null.

Returns
|null
SlaxWeb\Router\Container::getAll ( )

Get all Routes

Return all sotred routes as an array.

Returns
array
SlaxWeb\Router\Container::iterateRoutes ( string  $function)
protected

Iterate internal Routes array

Provides a unified method for iterating the Routes array with PHP functions, 'next', 'prev', 'current', and 'end'. Returns the Route on the position that is desired, if no Route is found, false is returned.

Parameters
string$functionFunction name for array iteration
Returns
|bool
SlaxWeb\Router\Container::next ( )

Get next Route

Get the next Route, if the current Route is not yet set, return the first Route. If no next element is found, false is returned.

Returns
|bool
SlaxWeb\Router\Container::prev ( )

Get previous Route

Get the previous Route, if the current Route is not yet set, return the last Route. If no previous element is found, false is returned.

Returns
|bool

The documentation for this class was generated from the following file: