MediaWiki
1.33.0
|
PathRouter class. More...
Public Member Functions | |
add ( $path, $params=[], $options=[]) | |
Add a new path pattern to the path router. More... | |
addStrict ( $path, $params=[], $options=[]) | |
Add a new path pattern to the path router with the strict option on. More... | |
parse ( $path) | |
Parse a path and return the query matches for the path. More... | |
Protected Member Functions | |
doAdd ( $path, $params, $options, $key=null) | |
Protected helper to do the actual bulk work of adding a single pattern. More... | |
internalParse ( $path) | |
Match a path against each defined pattern. More... | |
sortByWeight () | |
Protected helper to re-sort our patterns so that the most specific (most heavily weighted) patterns are at the start of the array. More... | |
Static Protected Member Functions | |
static | expandParamValue ( $pathMatches, $key, $value) |
Replace $key etc. More... | |
static | extractTitle ( $path, $pattern) |
static | makeWeight ( $pattern) |
Private Attributes | |
array | $patterns = [] |
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
array( 'title' => false )`Options:
Definition at line 73 of file PathRouter.php.
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 158 of file PathRouter.php.
References $options, $params, $path, as, and doAdd().
Referenced by addStrict(), WebRequest\getPathInfo(), PathRouterTest\setUp(), and PathRouterTest\testParse().
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 175 of file PathRouter.php.
References $options, $params, $path, and add().
Referenced by PathRouterTest\testWeight().
|
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 90 of file PathRouter.php.
References $options, $params, $path, as, makeWeight(), and object.
Referenced by 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 373 of file PathRouter.php.
Referenced by extractTitle().
|
staticprotected |
string | $path | |
object | $pattern |
Definition at line 279 of file PathRouter.php.
References $data, $matches, $path, $value, as, and expandParamValue().
Referenced by internalParse().
|
protected |
Match a path against each defined pattern.
string | $path |
Definition at line 262 of file PathRouter.php.
References $matches, $path, as, and extractTitle().
Referenced by parse().
|
staticprotected |
object | $pattern |
Definition at line 196 of file PathRouter.php.
Referenced by doAdd().
PathRouter::parse | ( | $path | ) |
Parse a path and return the query matches for the path.
string | $path | The path to parse |
Definition at line 236 of file PathRouter.php.
References $matches, $path, internalParse(), sortByWeight(), and wfRemoveDotSegments().
|
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 184 of file PathRouter.php.
References as.
Referenced by parse().
|
private |
Definition at line 78 of file PathRouter.php.