Stud.IP  6.0
Dispatcher Class Reference
Inheritance diagram for Dispatcher:
StudipDispatcher

Public Member Functions

 __construct (string $trails_root, string $trails_uri, string $default_controller)
 
 dispatch ($uri)
 
 map_uri_to_response ($uri)
 
 default_route ()
 
 trails_error ($exception)
 
 clean_request_uri ($uri)
 
 parse ($unconsumed, $controller=null)
 
 split_on_first_slash ($str)
 
 file_exists ($path)
 
 load_controller ($controller)
 
 error_handler ($errno, $string, $file, $line)
 

Data Fields

string $trails_root
 
string $trails_uri
 
string $default_controller
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( string  $trails_root,
string  $trails_uri,
string  $default_controller 
)
Parameters
string$trails_rootabsolute file path to a directory containing the applications controllers, views etc.
string$trails_urithe URI to which routes to mapped Controller/Actions are appended
string$default_controllerthe route to a controller, that is used if no controller is given, that is the route is equal to '/'

Member Function Documentation

◆ clean_request_uri()

clean_request_uri (   $uri)

Clean up URI string by removing the query part and leading slashes.

Parameters
string$urian URI string
Returns
string the cleaned string

◆ default_route()

default_route ( )
Returns
array an array containing the default controller and an empty unconsumed route
Exceptions
MissingFile

◆ dispatch()

dispatch (   $uri)

Maps a string to a response which is then rendered.

Parameters
string$uriThe requested URI.

◆ error_handler()

error_handler (   $errno,
  $string,
  $file,
  $line 
)

This method transforms E_USER_* and E_RECOVERABLE_ERROR to Exceptions.

Parameters
integer$errnothe level of the error raised
string$stringthe error message
string$filethe filename that the error was raised in
integer$linethe line number the error was raised at
Returns
bool
Exceptions
Exception

◆ file_exists()

file_exists (   $path)
Parameters
string$path
Returns
bool

◆ load_controller()

load_controller (   $controller)

Loads the controller file for a given controller path and return an instance of that controller. If an error occures, an exception will be thrown.

Parameters
string$controllerthe relative controller path
Returns
Controller an instance of that controller
Exceptions
UnknownController

◆ map_uri_to_response()

map_uri_to_response (   $uri)

Maps an URI to a response by figuring out first what controller to instantiate, then delegating the unconsumed part of the URI to the controller who returns an appropriate response object or throws an Exception.

Parameters
string$urithe URI string
Returns
Response a response object

◆ parse()

parse (   $unconsumed,
  $controller = null 
)
Parameters
string$unconsumed
string$controller
Returns
array
Exceptions
RoutingError

◆ split_on_first_slash()

split_on_first_slash (   $str)
Parameters
string$str
Returns
array

◆ trails_error()

trails_error (   $exception)

Field Documentation

◆ $default_controller

string $default_controller

This variable contains the route to the default controller.

◆ $trails_root

string $trails_root

This is the absolute file path to the trails application directory.

◆ $trails_uri

string $trails_uri

This is the URI to which routes to controller/actions are appended.


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