Providing functions / classes to handle URLs
This file is part of Ratatöskr. Ratatöskr is licensed unter the MIT / X11 License. See “ratatoeskr/licenses/ratatoeskr” for more information.
ratatoeskr/ | Providing functions / classes to handle URLs |
Functions | |
url_action_simple | Generate an action in a more simple way. |
url_action_subactions | Generate an action that contains subactions. |
url_action_alias | Generate an action that is an alias for another one (i.e. |
url_process | Choose an appropiate action for the given URL. |
Redirect | Exception that can be thrown inside an url_action_simple. |
NotFoundError | An Exception |
function url_action_simple( $function )
Generate an action in a more simple way.
$function | A callback that gets the $data var as an input and returns the new $data var. Can throw an Redirect Exception. |
A callback that can be used as an url action.
function url_process( $url, $actions, & $data )
Choose an appropiate action for the given URL.
$url | Either an array containing the URL components or the URL (both relative). |
$actions | Associative array of actions. Key is the name (anything alphanumeric, should usually not start with ‘_’, reserved for special URL names, see beneath). Value is a callback of the form: function(&$data, $url_now, &$url_next). $data can be used for shared data between subactions. $url_next can be modified in order to redirect to another action / stop the routing. |
_index | If name is empty, the index will be called. |
_default | If nothing was found, this is the default. |
_notfound | If not even _default exists or NotFoundError was thrown. |
_prelude | If existant, will be executed before everything else. |
_epilog | If existant, will be executed after evrything else. |
Exception that can be thrown inside an url_action_simple. throw new Redirect(array(“..”, “foo”)); will redirect to “../foo” and won’t touch $data.
Generate an action in a more simple way.
function url_action_simple( $function )
Generate an action that contains subactions.
function url_action_subactions( $actions )
Generate an action that is an alias for another one (i.e.
function url_action_alias( $for )
Choose an appropiate action for the given URL.
function url_process( $url, $actions, & $data )