MediaWiki
master
RedirectHandler.php
Go to the documentation of this file.
1
<?php
2
3
namespace
MediaWiki\Rest\Handler
;
4
5
use
MediaWiki\Config\ConfigException
;
6
use
MediaWiki\Rest\Handler
;
7
use
MediaWiki\Rest\Response
;
8
use
MediaWiki\Rest\RouteDefinitionException
;
9
14
class
RedirectHandler
extends
Handler
{
15
20
public
function
execute
() {
21
$path
= $this->
getConfig
()[
'redirect'
][
'path'
] ??
''
;
22
if
(
$path
===
''
) {
23
throw
new
RouteDefinitionException
(
'No registered redirect for this path'
);
24
}
25
$code = $this->
getConfig
()[
'redirect'
][
'code'
] ?? 308;
26
$pathParams = $this->
getRequest
()->getPathParams();
27
$queryParams = $this->
getRequest
()->getQueryParams();
28
$locationPath = $this->
getRouter
()->getRoutePath(
$path
, $pathParams, $queryParams );
29
$response = $this->
getResponseFactory
()->createRedirect( $locationPath, $code );
30
return
$response;
31
}
32
}
$path
$path
Definition
NoLocalSettings.php:27
MediaWiki\Config\ConfigException
Exceptions for config failures.
Definition
ConfigException.php:33
MediaWiki\Rest\Handler\RedirectHandler
Definition
RedirectHandler.php:14
MediaWiki\Rest\Handler\RedirectHandler\execute
execute()
Definition
RedirectHandler.php:20
MediaWiki\Rest\Handler
Base class for REST route handlers.
Definition
Handler.php:23
MediaWiki\Rest\Handler\getRequest
getRequest()
Get the current request.
Definition
Handler.php:318
MediaWiki\Rest\Handler\getConfig
getConfig()
Get the configuration array for the current route.
Definition
Handler.php:340
MediaWiki\Rest\Handler\getRouter
getRouter()
Get the Router.
Definition
Handler.php:257
MediaWiki\Rest\Handler\getResponseFactory
getResponseFactory()
Get the ResponseFactory which can be used to generate Response objects.
Definition
Handler.php:351
MediaWiki\Rest\Response
Definition
Response.php:8
MediaWiki\Rest\RouteDefinitionException
Definition
RouteDefinitionException.php:5
MediaWiki\Rest\Handler
Copyright (C) 2011-2020 Wikimedia Foundation and others.
Definition
ActionModuleBasedHandler.php:3
includes
Rest
Handler
RedirectHandler.php
Generated on Wed May 15 2024 19:23:03 for MediaWiki by
1.10.0