SiteRouter

Extends \Joomla\CMS\Router\Router

Class to create and parse routes for the site application

since

1.5

Methods

__construct

Class constructor

__construct(\Joomla\CMS\Application\CMSApplication $app = null, \Joomla\CMS\Menu\AbstractMenu $menu = null) 
since

3.4

Arguments

$app

\Joomla\CMS\Application\CMSApplicationJApplicationCms Object

$menu

\Joomla\CMS\Menu\AbstractMenuJMenu object

attachBuildRule

Attach a build rule

attachBuildRule(callable $callback, string $stage = self::PROCESS_DURING) : void
inherited
since

1.5

Arguments

$callback

callableThe function to be called

$stage

stringThe stage of the build process that this should be added to. Possible values: 'preprocess', '' for the main build process, 'postprocess'

attachParseRule

Attach a parse rule

attachParseRule(callable $callback, string $stage = self::PROCESS_DURING) : void
inherited
since

1.5

Arguments

$callback

callableThe function to be called.

$stage

stringThe stage of the parse process that this should be added to. Possible values: 'preprocess', '' for the main parse process, 'postprocess'

build

Function to convert an internal URI to a route

build(string|array|\Joomla\CMS\Uri\Uri $url) : \Joomla\CMS\Uri\Uri
inherited
since

1.5

Arguments

$url

string|array|\Joomla\CMS\Uri\UriThe internal URL or an associative array

Response

\Joomla\CMS\Uri\UriThe absolute search engine friendly URL object

buildBase

Add the basepath to the URI

buildBase( &$router,  &$uri) : void
since

4.0.0

Arguments

$router

$uri

buildComponentPreprocess

Run the component preprocess method

buildComponentPreprocess( &$router,  &$uri) : void
since

4.0.0

Arguments

$router

$uri

buildFormat

Build the format of the request

buildFormat( &$router,  &$uri) : void
since

4.0.0

Arguments

$router

$uri

buildInit

Do some initial processing for building a URL

buildInit( &$router,  &$uri) : void
since

4.0.0

Arguments

$router

$uri

buildPaginationData

Convert limits for pagination

buildPaginationData( &$router,  &$uri) : void
since

4.0.0

Arguments

$router

$uri

buildRewrite

Create a uri based on a full or partial URL string

buildRewrite( &$router,  &$uri) : void
since

4.0.0

Arguments

$router

$uri

buildSefRoute

Build the SEF route

buildSefRoute( &$router,  &$uri) : void
since

4.0.0

Arguments

$router

$uri

createUri

Create a uri based on a full or partial URL string

createUri(string $url) : \Joomla\CMS\Uri\Uri
inherited
since

3.2

Arguments

$url

stringThe URI or an associative array

Response

\Joomla\CMS\Uri\Uri

detachRule

Remove a rule

detachRule(string $type, callable $rule, string $stage = self::PROCESS_DURING) : boolean
inherited
since

4.0.0

throws

\InvalidArgumentException

Arguments

$type

stringType of rule to remove (parse or build)

$rule

callableThe rule to be removed.

$stage

stringThe stage of the parse process that this should be added to. Possible values: 'preprocess', '' for the main parse process, 'postprocess'

Response

booleanWas a rule removed?

getComponentRouter

Get component router

getComponentRouter(string $component) : \Joomla\CMS\Component\Router\RouterInterface
since

3.3

Arguments

$component

stringName of the component including com_ prefix

Response

\Joomla\CMS\Component\Router\RouterInterfaceComponent router

getInstance

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

getInstance(string $client, array $options = array()) : \Joomla\CMS\Router\Router
inherited static
since

1.5

throws

\RuntimeException

Arguments

$client

stringThe name of the client

$options

arrayAn associative array of options

Response

\Joomla\CMS\Router\RouterA Router object.

getRules

Get all currently attached rules

getRules() : array
inherited
since

4.0.0

Response

arrayAll currently attached rules in an array

getVar

Get a router variable

getVar(string $key) : mixed
inherited
since

1.5

Arguments

$key

stringThe name of the variable

Response

mixedValue of the variable

getVars

Get the router variable array

getVars() : array
inherited
since

1.5

Response

arrayAn associative array of router variables

parse

Function to convert a route to an internal URI

parse( &$uri, boolean $setVars = false) : array
inherited
since

1.5

throws

\Exception

Arguments

$uri

$setVars

booleanSet the parsed data in the internal storage for current-request-URLs

Response

array

parseCheckSSL

Force to SSL

parseCheckSSL( &$router,  &$uri) : void
since

4.0.0

Arguments

$router

$uri

parseFormat

Parse the format of the request

parseFormat( &$router,  &$uri) : void
since

4.0.0

Arguments

$router

$uri

parseInit

Do some initial cleanup before parsing the URL

parseInit( &$router,  &$uri) : void
since

4.0.0

Arguments

$router

$uri

parsePaginationData

Convert limits for pagination

parsePaginationData( &$router,  &$uri) : void
since

4.0.0

Arguments

$router

$uri

parseRawRoute

Convert a raw route to an internal URI

parseRawRoute( &$router,  &$uri) : void
since

4.0.0

Arguments

$router

$uri

parseSefRoute

Convert a sef route to an internal URI

parseSefRoute( &$router,  &$uri) : void
since

4.0.0

Arguments

$router

$uri

processBuildRules

Process the build uri query data based on custom defined rules

processBuildRules( &$uri, string $stage = self::PROCESS_DURING) : void
inherited
since

3.2

Arguments

$uri

$stage

stringThe stage that should be processed. Possible values: 'preprocess', 'postprocess' and '' for the main build stage

processParseRules

Process the parsed router variables based on custom defined rules

processParseRules( &$uri, string $stage = self::PROCESS_DURING) : void
inherited
since

3.2

Arguments

$uri

$stage

stringThe stage that should be processed. Possible values: 'preprocess', 'postprocess' and '' for the main parse stage

setComponentRouter

Set a router for a component

setComponentRouter(string $component, object $router) : boolean
since

3.3

Arguments

$component

stringComponent name with com_ prefix

$router

objectComponent router

Response

booleanTrue if the router was accepted, false if not

setVar

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

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

1.5

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
inherited
since

1.5

Arguments

$vars

arrayAn associative array with variables

$merge

booleanIf True, the array will be merged instead of overwritten

Constants

PROCESS_BEFORE

Mask for the before process stage

inherited
Value 'preprocess'
since

3.4

Type(s)

string

PROCESS_DURING

Mask for the during process stage

inherited
Value ''
since

3.4

Type(s)

string

PROCESS_AFTER

Mask for the after process stage

inherited
Value 'postprocess'
since

3.4

Type(s)

string

Properties

componentRouters

Component-router objects

since

3.3

Type(s)

array

app

Current Application-Object

menu

Current Menu-Object

since

3.4

Type(s)

\Joomla\CMS\Menu\AbstractMenu

vars

An array of variables

inherited
since

1.5

Type(s)

array

rules

An array of rules

inherited
since

1.5

Type(s)

array

cache

Caching of processed URIs

inherited
since

3.3

Type(s)

array

instances

Router instances container.

inherited static
since

1.7

Type(s)

array<mixed,\Joomla\CMS\Router\Router>