JRouter

Extends \JObject

Class to create and parse routes

This class allows for simple but smart objects with get and set methods and an internal error handler.

package

Joomla.Platform

subpackage

Application

since

11.1

Methods

__construct

Class constructor, overridden in descendant classes.

__construct(mixed $properties = null) 
inherited
since

11.1

Arguments

$properties

mixedEither and associative array or another object to set the initial properties of the object.

__toString

Magic method to convert the object to a string gracefully.

__toString() : string
inherited deprecated
since

11.1

deprecated

12.3 Classes should provide their own __toString() implementation.

Response

stringThe classname.

_buildRawRoute

Function to build a raw route

_buildRawRoute( &$uri) : string
since

11.1

Arguments

$uri

Response

stringRaw Route

_buildSefRoute

Function to build a sef route

_buildSefRoute( &$uri) : string
since

11.1

Arguments

$uri

Response

stringThe SEF route

_createURI

Create a uri based on a full or partial url string

_createURI(string $url) : \JURI
since

11.1

Arguments

$url

stringThe URI

Response

\JURI

_decodeSegments

Decode route segments

_decodeSegments(array $segments) : array
since

11.1

Arguments

$segments

arrayAn array of route segments

Response

arrayArray of decoded route segments

_encodeSegments

Encode route segments

_encodeSegments(array $segments) : array
since

11.1

Arguments

$segments

arrayAn array of route segments

Response

arrayArray of encoded route segments

_parseRawRoute

Function to convert a raw route to an internal URI

_parseRawRoute( &$uri) : boolean
since

11.1

Arguments

$uri

Response

boolean

_parseSefRoute

Function to convert a sef route to an internal URI

_parseSefRoute( &$uri) : string
since

11.1

Arguments

$uri

Response

stringInternal URI

_processBuildRules

Process the build uri query data based on custom defined rules

_processBuildRules( &$uri) : void
since

11.1

Arguments

$uri

_processParseRules

Process the parsed router variables based on custom defined rules

_processParseRules( &$uri) : array
since

11.1

Arguments

$uri

Response

arrayThe array of processed URI variables

attachBuildRule

Attach a build rule

attachBuildRule(callback $callback) : void
since

11.1.

Arguments

$callback

callbackThe function to be called

attachParseRule

Attach a parse rule

attachParseRule(callback $callback) : void
since

11.1

Arguments

$callback

callbackThe function to be called.

build

Function to convert an internal URI to a route

build(string $url) : string
since

11.1

Arguments

$url

stringThe internal URL

Response

stringThe absolute search engine friendly URL

def

Sets a default value if not alreay assigned

def(string $property, mixed $default = null) : mixed
inherited
since

11.1

Arguments

$property

stringThe name of the property.

$default

mixedThe default value.

Response

mixed

get

Returns a property of the object or the default value if the property is not set.

get(string $property, mixed $default = null) : mixed
inherited
since

11.1

see \JObject::getProperties()

Arguments

$property

stringThe name of the property.

$default

mixedThe default value.

Response

mixedThe value of the property.

getError

Get the most recent error message.

getError(integer $i = null, boolean $toString = true) : string
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$i

integerOption error index.

$toString

booleanIndicates if JError objects should return their error message.

Response

stringError message

getErrors

Return all errors, if any.

getErrors() : array
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Response

arrayArray of error messages or JErrors.

getInstance

Returns the global JRouter object, only creating it if it doesn't already exist.

getInstance(string $client, array $options = array()) : \JRouter
static
since

11.1

Arguments

$client

stringThe name of the client

$options

arrayAn associative array of options

Response

\JRouterA JRouter object.

getMode

Get the router mode

getMode() : integer
since

11.1

Response

integer

getProperties

Returns an associative array of object properties.

getProperties(boolean $public = true) : array
inherited
since

11.1

see \JObject::get()

Arguments

$public

booleanIf true, returns only the public properties.

Response

array

getVar

Get a router variable

getVar(string $key) : mixed
since

11.1

Arguments

$key

stringThe name of the variable

Response

mixedValue of the variable

getVars

Get the router variable array

getVars() : array
since

11.1

Response

arrayAn associative array of router variables

parse

Function to convert a route to an internal URI

parse( &$uri) : array
since

11.1

Arguments

$uri

Response

array

set

Modifies a property of the object, creating it if it does not already exist.

set(string $property, mixed $value = null) : mixed
inherited
since

11.1

Arguments

$property

stringThe name of the property.

$value

mixedThe value of the property to set.

Response

mixedPrevious value of the property.

setError

Add an error message.

setError(string $error) : void
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$error

stringError message.

setMode

Set the router mode

setMode(integer $mode) : void
since

11.1

Arguments

$mode

integerThe routing mode.

setProperties

Set the object properties based on a named array/hash.

setProperties(mixed $properties) : boolean
inherited
since

11.1

see \JObject::set()

Arguments

$properties

mixedEither an associative array or another object.

Response

boolean

setVar

Set a router variable, creating it if it doesn't exist

setVar(string $key, mixed $value, boolean $create = true) : void
since

11.1

Arguments

$key

stringThe name of the variable

$value

mixedThe value of the variable

$create

booleanIf True, the variable will be created if it doesn't exist yet

setVars

Set the router variable array

setVars(array $vars = array(), boolean $merge = true) : void
since

11.1

Arguments

$vars

arrayAn associative array with variables

$merge

booleanIf True, the array will be merged instead of overwritten

toString

Converts the object to a string (the class name).

toString() : string
inherited deprecated
since

11.1

deprecated

12.1 Use magic method __toString()

see \JObject::__toString()

Response

string

Properties

mode

The rewrite mode

since

11.1

Type(s)

integer

_mode

The rewrite mode

deprecated
since

11.1

deprecated

use $mode declare as private

Type(s)

integer

vars

An array of variables

since

11.1

Type(s)

array

_vars

An array of variables

deprecated
since

11.1

deprecated

use $vars declare as private

Type(s)

array

rules

An array of rules

since

11.1

Type(s)

array

_rules

An array of rules

deprecated
since

11.1

deprecated

use $rules declare as private

Type(s)

array

instances

JRouter instances container.

static
since

11.3

Type(s)

array

_errors

An array of error messages or Exception objects.

inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Type(s)

array