X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FPathRouter.php;h=4d7bd38149df42c97ed27af6747693b83e031bb8;hb=6d5d0c9fb78cb3d436051640af6bd4e8db574512;hp=eb52d7cd23d9ce415aea7afdaf93b69e1053ba32;hpb=08e27d6d40ed2f6eea8abc509254e11c92212a8d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/PathRouter.php b/includes/PathRouter.php index eb52d7cd23..4d7bd38149 100644 --- a/includes/PathRouter.php +++ b/includes/PathRouter.php @@ -53,8 +53,8 @@ * - In a pattern $1, $2, etc... will be replaced with the relevant contents * - If you used a keyed array as a path pattern, $key will be replaced with * the relevant contents - * - The default behavior is equivalent to `array( 'title' => '$1' )`, - * if you don't want the title parameter you can explicitly use `array( 'title' => false )` + * - The default behavior is equivalent to `[ 'title' => '$1' ]`, + * 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' ];` * @@ -80,7 +80,7 @@ class PathRouter { /** * 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 + * a single string $path and an array $path that contains multiple path * patterns each with an associated $key to pass on. * @param string $path * @param array $params @@ -247,9 +247,9 @@ class PathRouter { } // We know the difference between null (no matches) and - // array() (a match with no data) but our WebRequest caller - // expects array() even when we have no matches so return - // a array() when we have null + // [] (a match with no data) but our WebRequest caller + // expects [] even when we have no matches so return + // a [] when we have null return $matches ?? []; } @@ -401,4 +401,22 @@ class PathRouter { return $value; } + + /** + * @internal For use by Title and WebRequest only. + * @param array $actionPaths + * @param string $articlePath + * @return string[]|false + */ + public static function getActionPaths( array $actionPaths, $articlePath ) { + if ( !$actionPaths ) { + return false; + } + // Processing of urls for this feature requires that 'view' is set. + // By default, set it to the pretty article path. + if ( !isset( $actionPaths['view'] ) ) { + $actionPaths['view'] = $articlePath; + } + return $actionPaths; + } }