SiteRouter

Extends Router

Class to create and parse routes for the site application

since

1.5

package

Joomla CMS

Methods

__construct

Class constructor

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

3.4

Arguments

app

CMSApplicationApplication Object

menu

AbstractMenuMenu object

Response

mixed

attachBuildRule

Attach a build rule

attachBuildRule(
Warning: Array to string conversion in /opt/phpdoc/vendor/twig/twig/src/Extension/CoreExtension.php on line 768
|Array callback,  stage = self::PROCESS_DURING) : 
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'

Response

void

attachParseRule

Attach a parse rule

attachParseRule(
Warning: Array to string conversion in /opt/phpdoc/vendor/twig/twig/src/Extension/CoreExtension.php on line 768
|Array callback,  stage = self::PROCESS_DURING) : 
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'

Response

void

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<string|int, mixed>|UriThe internal URL or an associative array

Response

UriThe absolute search engine friendly URL object

buildBase

Add the basepath to the URI

buildBase(\Joomla\CMS\Router\SiteRouter &router, \Joomla\CMS\Uri\Uri &uri) : 
since

4.0.0

Arguments

router

SiteRouterRouter object

uri

UriURI object to process

Response

void

buildComponentPreprocess

Run the component preprocess method

buildComponentPreprocess(\Joomla\CMS\Router\SiteRouter &router, \Joomla\CMS\Uri\Uri &uri) : 
since

4.0.0

Arguments

router

SiteRouterRouter object

uri

UriURI object to process

Response

void

buildFormat

Build the format of the request

buildFormat(\Joomla\CMS\Router\SiteRouter &router, \Joomla\CMS\Uri\Uri &uri) : 
since

4.0.0

Arguments

router

SiteRouterRouter object

uri

UriURI object to process

Response

void

buildInit

Do some initial processing for building a URL

buildInit(\Joomla\CMS\Router\SiteRouter &router, \Joomla\CMS\Uri\Uri &uri) : 
since

4.0.0

Arguments

router

SiteRouterRouter object

uri

UriURI object to process

Response

void

buildPaginationData

Convert limits for pagination

buildPaginationData(\Joomla\CMS\Router\SiteRouter &router, \Joomla\CMS\Uri\Uri &uri) : 
since

4.0.0

Arguments

router

SiteRouterRouter object

uri

UriURI object to process

Response

void

buildRewrite

Create a uri based on a full or partial URL string

buildRewrite(\Joomla\CMS\Router\SiteRouter &router, \Joomla\CMS\Uri\Uri &uri) : 
since

4.0.0

Arguments

router

SiteRouterRouter object

uri

UriURI object to process

Response

void

buildSefRoute

Build the SEF route

buildSefRoute(\Joomla\CMS\Router\SiteRouter &router, \Joomla\CMS\Uri\Uri &uri) : 
since

4.0.0

Arguments

router

SiteRouterRouter object

uri

UriURI object to process

Response

void

createUri

Create a uri based on a full or partial URL string

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

3.2

Arguments

url

stringThe URI or an associative array

Response

Uri

detachRule

Remove a rule

detachRule( type, 
Warning: Array to string conversion in /opt/phpdoc/vendor/twig/twig/src/Extension/CoreExtension.php on line 768
|Array rule,  stage = self::PROCESS_DURING) : 
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

boolWas a rule removed?

getComponentRouter

Get component router

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

3.3

Arguments

component

stringName of the component including com_ prefix

Response

RouterInterfaceComponent router

getInstance

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

getInstance( client, mixed||string|int options = []) : \Joomla\CMS\Router\Router
inherited static deprecated
since

1.5

throws

RuntimeException

deprecated

4.0 will be removed in 6.0 Inject the router or load it from the dependency injection container Example: Factory::getContainer()->get(SiteRouter::class);

Arguments

client

stringThe name of the client

options

array<string|int, mixed>An associative array of options

Response

RouterA Router object.

getRules

Get all currently attached rules

getRules() : mixed||string|int
inherited
since

4.0.0

Response

array<string|int, mixed>All currently attached rules in an array

getVar

Get a router variable

getVar( key) : 
inherited
since

1.5

Arguments

key

stringThe name of the variable

Response

mixedValue of the variable

getVars

Get the router variable array

getVars() : mixed||string|int
inherited
since

1.5

Response

array<string|int, mixed>An associative array of router variables

parse

Function to convert a route to an internal URI

parse(\Joomla\CMS\Uri\Uri &uri,  setVars = false) : mixed||string|int
inherited
since

1.5

throws

Exception

Arguments

uri

UriThe uri.

setVars

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

Response

array<string|int, mixed>

parseCheckSSL

Force to SSL

parseCheckSSL(\Joomla\CMS\Router\Router &router, \Joomla\CMS\Uri\Uri &uri) : 
since

4.0.0

Arguments

router

RouterRouter object

uri

UriURI object to process

Response

void

parseFormat

Parse the format of the request

parseFormat(\Joomla\CMS\Router\SiteRouter &router, \Joomla\CMS\Uri\Uri &uri) : 
since

4.0.0

Arguments

router

SiteRouterRouter object

uri

UriURI object to process

Response

void

parseInit

Do some initial cleanup before parsing the URL

parseInit(\Joomla\CMS\Router\SiteRouter &router, \Joomla\CMS\Uri\Uri &uri) : 
since

4.0.0

Arguments

router

SiteRouterRouter object

uri

UriURI object to process

Response

void

parsePaginationData

Convert limits for pagination

parsePaginationData(\Joomla\CMS\Router\SiteRouter &router, \Joomla\CMS\Uri\Uri &uri) : 
since

4.0.0

Arguments

router

SiteRouterRouter object

uri

UriURI object to process

Response

void

parseRawRoute

Convert a raw route to an internal URI

parseRawRoute(\Joomla\CMS\Router\SiteRouter &router, \Joomla\CMS\Uri\Uri &uri) : 
since

4.0.0

Arguments

router

SiteRouterRouter object

uri

UriURI object to process

Response

void

parseSefRoute

Convert a sef route to an internal URI

parseSefRoute(\Joomla\CMS\Router\SiteRouter &router, \Joomla\CMS\Uri\Uri &uri) : 
since

4.0.0

Arguments

router

SiteRouterRouter object

uri

UriURI object to process

Response

void

processBuildRules

Process the build uri query data based on custom defined rules

processBuildRules(\Joomla\CMS\Uri\Uri &uri,  stage = self::PROCESS_DURING) : 
inherited
since

3.2

Arguments

uri

UriThe URI

stage

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

Response

void

processParseRules

Process the parsed router variables based on custom defined rules

processParseRules(\Joomla\CMS\Uri\Uri &uri,  stage = self::PROCESS_DURING) : 
inherited
since

3.2

Arguments

uri

UriThe URI to parse

stage

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

Response

void

setComponentRouter

Set a router for a component

setComponentRouter( component,  router) : 
since

3.3

Arguments

component

stringComponent name with com_ prefix

router

objectComponent router

Response

boolTrue if the router was accepted, false if not

setVar

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

setVar( key,  value,  create = true) : 
inherited
since

1.5

Arguments

key

stringThe name of the variable

value

mixedThe value of the variable

create

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

Response

void

setVars

Set the router variable array

setVars(mixed||string|int vars = [],  merge = true) : 
inherited
since

1.5

Arguments

vars

array<string|int, mixed>An associative array with variables

merge

boolIf True, the array will be merged instead of overwritten

Response

void

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

vars

An array of variables

inherited
since

1.5

Type(s)

array<string|int, mixed>

rules

An array of rules

inherited
since

1.5

Type(s)

array<string|int, mixed>

cache

Caching of processed URIs

inherited
since

3.3

Type(s)

array<string|int, mixed>

instances

Router instances container.

inherited static
since

1.7

Type(s)

array<string|int, Router>

componentRouters

Component-router objects

since

3.3

Type(s)

array<string|int, mixed>

app

since

3.4

Type(s)

CMSApplication

menu

Current Menu-Object

since

3.4

Type(s)

AbstractMenu