JRouter
Extends \JObjectClass 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)
since |
11.1 |
---|
Arguments
- $properties
mixed
Either 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
since |
11.1 |
---|---|
deprecated |
12.3 Classes should provide their own __toString() implementation. |
Response
string
The classname.
_buildRawRoute
Function to build a raw route
_buildRawRoute( &$uri) : string
since |
11.1 |
---|
Arguments
- $uri
Response
string
Raw Route
_buildSefRoute
Function to build a sef route
_buildSefRoute( &$uri) : string
since |
11.1 |
---|
Arguments
- $uri
Response
string
The SEF route
_createURI
Create a uri based on a full or partial url string
_createURI(string $url) : \JURI
_decodeSegments
Decode route segments
_decodeSegments(array $segments) : array
since |
11.1 |
---|
Arguments
- $segments
array
An array of route segments
Response
array
Array of decoded route segments
_encodeSegments
Encode route segments
_encodeSegments(array $segments) : array
since |
11.1 |
---|
Arguments
- $segments
array
An array of route segments
Response
array
Array 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
string
Internal 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
array
The array of processed URI variables
attachBuildRule
Attach a build rule
attachBuildRule(callback $callback) : void
since |
11.1. |
---|
Arguments
- $callback
callback
The function to be called
attachParseRule
Attach a parse rule
attachParseRule(callback $callback) : void
since |
11.1 |
---|
Arguments
- $callback
callback
The function to be called.
build
Function to convert an internal URI to a route
build(string $url) : string
since |
11.1 |
---|
Arguments
- $url
string
The internal URL
Response
string
The absolute search engine friendly URL
def
Sets a default value if not alreay assigned
def(string $property, mixed $default = null) : mixed
since |
11.1 |
---|
Arguments
- $property
string
The name of the property.- $default
mixed
The 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
since |
11.1 |
---|---|
see | \JObject::getProperties() |
Arguments
- $property
string
The name of the property.- $default
mixed
The default value.
Response
mixed
The value of the property.
getError
Get the most recent error message.
getError(integer $i = null, boolean $toString = true) : string
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Arguments
- $i
integer
Option error index.- $toString
boolean
Indicates if JError objects should return their error message.
Response
string
Error message
getErrors
Return all errors, if any.
getErrors() : array
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Response
array
Array 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
since |
11.1 |
---|
Arguments
- $client
string
The name of the client- $options
array
An associative array of options
Response
\JRouter
A 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
since |
11.1 |
---|---|
see | \JObject::get() |
Arguments
- $public
boolean
If true, returns only the public properties.
Response
array
getVar
Get a router variable
getVar(string $key) : mixed
since |
11.1 |
---|
Arguments
- $key
string
The name of the variable
Response
mixed
Value of the variable
getVars
Get the router variable array
getVars() : array
since |
11.1 |
---|
Response
array
An 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
since |
11.1 |
---|
Arguments
- $property
string
The name of the property.- $value
mixed
The value of the property to set.
Response
mixed
Previous value of the property.
setError
Add an error message.
setError(string $error) : void
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Arguments
- $error
string
Error message.
setMode
Set the router mode
setMode(integer $mode) : void
since |
11.1 |
---|
Arguments
- $mode
integer
The routing mode.
setProperties
Set the object properties based on a named array/hash.
setProperties(mixed $properties) : boolean
since |
11.1 |
---|---|
see | \JObject::set() |
Arguments
- $properties
mixed
Either 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
string
The name of the variable- $value
mixed
The value of the variable- $create
boolean
If 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
array
An associative array with variables- $merge
boolean
If True, the array will be merged instead of overwritten
toString
Converts the object to a string (the class name).
toString() : string
Properties
mode
The rewrite mode
since |
11.1 |
---|
Type(s)
integer
_mode
The rewrite mode
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
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
since |
11.1 |
---|---|
deprecated |
use $rules declare as private |
Type(s)
array
instances
JRouter instances container.
since |
11.3 |
---|
Type(s)
array
_errors
An array of error messages or Exception objects.