MediaWiki master
|
MediaWiki\Request\PathRouter class. More...
Public Member Functions | |
add ( $path, $params=[], $options=[]) | |
Add a new path pattern to the path router. | |
addStrict ( $path, $params=[], $options=[]) | |
Add a new path pattern to the path router with the strict option on. | |
parse ( $path) | |
Parse a path and return the query matches for the path. | |
validateRoute ( $path, $varName) | |
Static Public Member Functions | |
static | getActionPaths (array $actionPaths, $articlePath) |
Protected Member Functions | |
doAdd ( $path, $params, $options, $key=null) | |
Protected helper to do the actual bulk work of adding a single pattern. | |
internalParse ( $path) | |
Match a path against each defined pattern. | |
sortByWeight () | |
Protected helper to re-sort our patterns so that the most specific (most heavily weighted) patterns are at the start of the array. | |
Static Protected Member Functions | |
static | expandParamValue ( $pathMatches, $key, $value) |
Replace $key etc. | |
static | extractTitle ( $path, $pattern) |
static | makeWeight ( $pattern) |
MediaWiki\Request\PathRouter class.
This class can take patterns such as /wiki/$1 and use them to parse query parameters out of REQUEST_URI paths.
$router->add( "/wiki/$1" );
Path patterns:
Params:
, if you don't want the title parameter you can explicitly use
[ 'title' => false ]
You can specify a value that won't have replacements in it using
'foo' => [ 'value' => 'bar' ];`Options:
Definition at line 79 of file PathRouter.php.
MediaWiki\Request\PathRouter::add | ( | $path, | |
$params = [], | |||
$options = [] ) |
Add a new path pattern to the path router.
string | array | $path | The path pattern to add |
array | $params | The params for this path pattern |
array | $options | The options for this path pattern |
Definition at line 164 of file PathRouter.php.
References $params, $path, and MediaWiki\Request\PathRouter\doAdd().
Referenced by MediaWiki\Request\PathRouter\addStrict(), and MediaWiki\Request\WebRequest\getPathInfo().
MediaWiki\Request\PathRouter::addStrict | ( | $path, | |
$params = [], | |||
$options = [] ) |
Add a new path pattern to the path router with the strict option on.
string | array | $path | |
array | $params | |
array | $options |
Definition at line 200 of file PathRouter.php.
References $params, $path, and MediaWiki\Request\PathRouter\add().
|
protected |
Protected helper to do the actual bulk work of adding a single pattern.
This is in a separate method so that add() can handle the difference between a single string $path and an array $path that contains multiple path patterns each with an associated $key to pass on.
string | $path | |
array | $params | |
array | $options | |
null | string | $key |
Definition at line 96 of file PathRouter.php.
References $params, $path, and MediaWiki\Request\PathRouter\makeWeight().
Referenced by MediaWiki\Request\PathRouter\add().
|
staticprotected |
Replace $key etc.
in param values with the matched strings from the path.
array | $pathMatches | The match results from the path |
string | null | $key | The key of the matching pattern |
string | $value | The param value to be expanded |
Definition at line 398 of file PathRouter.php.
Referenced by MediaWiki\Request\PathRouter\extractTitle().
|
staticprotected |
string | $path | |
stdClass | $pattern |
Definition at line 304 of file PathRouter.php.
References $matches, $path, and MediaWiki\Request\PathRouter\expandParamValue().
Referenced by MediaWiki\Request\PathRouter\internalParse().
|
static |
array | $actionPaths | |
string | $articlePath |
Definition at line 436 of file PathRouter.php.
Referenced by MediaWiki\Request\WebRequest\getPathInfo().
|
protected |
Match a path against each defined pattern.
string | $path |
Definition at line 287 of file PathRouter.php.
References $matches, $path, and MediaWiki\Request\PathRouter\extractTitle().
Referenced by MediaWiki\Request\PathRouter\parse().
|
staticprotected |
stdClass | $pattern |
Definition at line 221 of file PathRouter.php.
References $path.
Referenced by MediaWiki\Request\PathRouter\doAdd().
MediaWiki\Request\PathRouter::parse | ( | $path | ) |
Parse a path and return the query matches for the path.
string | $path | The path to parse |
Definition at line 261 of file PathRouter.php.
References $matches, $path, MediaWiki\Request\PathRouter\internalParse(), and MediaWiki\Request\PathRouter\sortByWeight().
|
protected |
Protected helper to re-sort our patterns so that the most specific (most heavily weighted) patterns are at the start of the array.
Definition at line 209 of file PathRouter.php.
Referenced by MediaWiki\Request\PathRouter\parse().
MediaWiki\Request\PathRouter::validateRoute | ( | $path, | |
$varName ) |
string | $path | To be given to add() |
string | $varName | Full name of configuration variable for use in error message and url to mediawiki.org Manual (e.g. "wgExample"). |
FatalError | If path is invalid |
Definition at line 181 of file PathRouter.php.
References $path.