NanoFramework 1.4.0
A tiny PHP Framework
Static Public Member Functions | Static Protected Member Functions | Static Protected Attributes
Route Class Reference

Maps the URIs to the Controllers. More...

Static Public Member Functions

static load (string $source)
 
static setNamespace (string $namespace)
 
static getNamespace ()
 
static getSpecificRoutes ()
 
static display ()
 
static analyzeError (\Error $e)
 

Static Protected Member Functions

static getUri (string $uri)
 

Static Protected Attributes

static $namespace = 'App'
 
static $specificRoutes = []
 

Detailed Description

Maps the URIs to the Controllers.

This class is used to call a specific Controller based on a given route.

Definition at line 10 of file Route.php.

Member Function Documentation

◆ analyzeError()

static analyzeError ( \Error  $e)
static

When first running NanoFramework, if something is not correcly set, this method intercepts the error and displays the message explaining how to fix it.

Definition at line 137 of file Route.php.

◆ display()

static display ( )
static

Displays the correct page based on the URI.

If the URI is found in the list of specific routes, it is first translated into a standard route. The corresponding Controller is then called.

This method intercepts RedirectException to redirect to the correct location.

Definition at line 104 of file Route.php.

◆ getNamespace()

static getNamespace ( )
static

Shows the current namespace used by this class.

Returns
string The current namespace

Definition at line 82 of file Route.php.

◆ getSpecificRoutes()

static getSpecificRoutes ( )
static

Lists a deep copy of all the specific routes saved in the current class.

Returns
array All the specific routes recorded

Definition at line 92 of file Route.php.

◆ getUri()

static getUri ( string  $uri)
staticprotected

This method allows to translate a specific route into a standard route.

Parameters
string$urithe specific URI to translate
Returns
string The standard corresponding URI

Definition at line 164 of file Route.php.

◆ load()

static load ( string  $source)
static

Loads a route file located at the provided place and populates the Route::specificRoutes attribute.

See routeSyntax for more information about the syntax of the routes file.

Parameters
string$sourcethe location of the routes files

Definition at line 29 of file Route.php.

◆ setNamespace()

static setNamespace ( string  $namespace)
static

Sets the namespace to a custom value.

Parameters
string$namespacethe new namespace for the user-defined classes

Definition at line 72 of file Route.php.

Field Documentation

◆ $namespace

$namespace = 'App'
staticprotected

The namespace where to find the code written by the user.

Definition at line 15 of file Route.php.

◆ $specificRoutes

$specificRoutes = []
staticprotected

The list of the routes that don't match the default pattern.

Definition at line 20 of file Route.php.


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