Class Router
Handles mapping of URIs from one type to another
Final
Package: minPHP\
lib
Located at lib/router.php
Methods summary
protected
|
#
__construct( )
Protected constructor to prevent instance creation
Protected constructor to prevent instance creation
|
public static
|
#
route( string $orig_uri, string $mapped_uri )
Sets a route from $orig_uri to $mapped_uri
Sets a route from $orig_uri to $mapped_uri
Parameters
- $orig_uri
string $orig_uri The original URI to map from
- $mapped_uri
string $mapped_uri The destination URI to map to
|
public static
string
|
#
match( string $request )
Maps the requested URI to the proper re-mapped URI, if available
Maps the requested URI to the proper re-mapped URI, if available
Parameters
Returns
string The new URI, or the requested URI if no mapping exists for this request
|
public static
string
|
#
escape( string $uri )
Escapes a URI, making it safe for preg (regex) functions
Escapes a URI, making it safe for preg (regex) functions
Parameters
- $uri
string $uri The URI to be escaped
Returns
string the escaped $uri string
|
public static
string
|
#
unescape( string $uri )
Unescapes a URI that has been escaped with Router::escape()
Unescapes a URI that has been escaped with Router::escape()
Parameters
- $uri
string $uri The URI to be unescaped
Returns
string the unescaped $uri string
|
public static
|
#
makeURI( mixed $dir )
Converts a directory string into a properly formed URI
Converts a directory string into a properly formed URI
|
public static
array
|
#
parseURI( string $uri )
Parses the given URI into an array of its components
Parses the given URI into an array of its components
Parameters
- $uri
string $uri The URI to parse
Returns
array The URI broken into its many parts
|
public static
string
|
#
filterURI( string $uri )
Filters out any part of the web root from the uri path
Filters out any part of the web root from the uri path
Parameters
- $uri
string $uri The URI to filter
Returns
string The filtered URI
|
public static
boolean
|
#
isCallable( Object $obj, string $method, string $inherits_from = "Controller" )
Uses PHP's ReflectionClass to test the given object for the given method's
callability. Only public, non-abstract, non-constructor/destructors are
considered callable.
Uses PHP's ReflectionClass to test the given object for the given method's
callability. Only public, non-abstract, non-constructor/destructors are
considered callable.
Parameters
- $obj
Object $obj The object we're searching
- $method
string $method The name of the method we're looking for in $obj
- $inherits_from
string $inherits_from The class that $obj must inherit from, null otherwise.
Returns
boolean true if the method is callable, false otherwise.
|
public static
array
|
#
routesTo( string $request_uri )
Finds the controller and action and all get parameters that the given URI
routes to
Finds the controller and action and all get parameters that the given URI
routes to
Parameters
- $request_uri
string $request_uri A URI to parse
Returns
array An array containing the following indexes: - controller The name of the
controller this URI maps to - action The action method this URI maps to - get An
array of get parameters this URI maps to - uri An array of URI parts - uri_str A
string representation of the URI containing the controller requested (if no
passed in the URI)
|
Magic methods summary
Properties summary
protected static
array
|
$routes |
#
A 2-dimensional array containg the original URIs and their mapped counter
parts
A 2-dimensional array containg the original URIs and their mapped counter
parts
|