Chyrp

Route

Holds information for URLs, redirecting, etc.

Summary
Route Holds information for URLs, redirecting, etc.
Variables
$action The current action.
$try An array of (string) actions to try until one doesn’t return false.
$ajax Shortcut to the AJAX constant (useful for Twig).
$success Did Route.init call a successful route?
$feed Is the visitor requesting a feed?
$controller The Route’s Controller.
Functions
__construct Parse the URL to determine what to do.
init Begin running Controller actions until one of them doesn’t return false.
url Attempts to change the specified clean URL to a dirty URL if clean URLs is disabled.  Use this for linking to things.  The applicable URL conversions are passed through the parse_urls trigger.
add Adds a route to Chyrp.  Only needed for actions that have more than one parameter.  For example, for /tags/ you won’t need to do this, but you will for /tag/tag-name/.
route Removes a route added by add.
current Returns a singleton reference to the current class.

Variables

$action

public $action

The current action.

$try

public $try

An array of (string) actions to try until one doesn’t return false.

$ajax

public $ajax

Shortcut to the AJAX constant (useful for Twig).

$success

public $success

Did Route.init call a successful route?

$feed

public $feed

Is the visitor requesting a feed?

$controller

public $controller

The Route’s Controller.

Functions

__construct

private function __construct( $controller )

Parse the URL to determine what to do.

init

public function init()

Begin running Controller actions until one of them doesn’t return false.

This will also call the route_xxxxx Triggers.

Parameters

$controller The Controller to run methods on.

url

public function url( $url,   
$use_chyrp_url  =  false )

Attempts to change the specified clean URL to a dirty URL if clean URLs is disabled.  Use this for linking to things.  The applicable URL conversions are passed through the parse_urls trigger.

Parameters

$url The clean URL.

Returns

Clean URL if $config->clean_urls is set to true.
Dirty URL if $config->clean_urls is set to false.

add

public function add( $path,
$action )

Adds a route to Chyrp.  Only needed for actions that have more than one parameter.  For example, for /tags/ you won’t need to do this, but you will for /tag/tag-name/.

Parameters

$path The path to add.  Wrap variables with parentheses, e.g.  “tag/(name)/”.
$action The action the path points to.

See Also

<remove>

route

Removes a route added by add.

Parameters

$path The path to remove.  Same as add.

See Also

add

current

public static function & current( $controller  =  null )

Returns a singleton reference to the current class.