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
31
class
RedirectHandler
extends
Handler
{
32
37
public
function
execute
() {
38
$path
= $this->
getConfig
()[
'redirect'
][
'path'
] ??
''
;
39
if
(
$path
===
''
) {
40
throw
new
RouteDefinitionException
(
'No registered redirect for this path'
);
41
}
42
$code = $this->
getConfig
()[
'redirect'
][
'code'
] ?? 308;
43
$pathParams = $this->
getRequest
()->getPathParams();
44
$queryParams = $this->
getRequest
()->getQueryParams();
45
$locationPath = $this->
getRouter
()->getRoutePath(
$path
, $pathParams, $queryParams );
46
$response = $this->
getResponseFactory
()->createRedirect( $locationPath, $code );
47
return
$response;
48
}
49
}
$path
$path
Definition
NoLocalSettings.php:28
MediaWiki\Config\ConfigException
Exceptions for config failures.
Definition
ConfigException.php:33
MediaWiki\Rest\Handler\RedirectHandler
Definition
RedirectHandler.php:31
MediaWiki\Rest\Handler\RedirectHandler\execute
execute()
Definition
RedirectHandler.php:37
MediaWiki\Rest\Handler
Base class for REST route handlers.
Definition
Handler.php:25
MediaWiki\Rest\Handler\getRequest
getRequest()
Get the current request.
Definition
Handler.php:332
MediaWiki\Rest\Handler\getConfig
getConfig()
Get the configuration array for the current route.
Definition
Handler.php:354
MediaWiki\Rest\Handler\getRouter
getRouter()
Get the Router.
Definition
Handler.php:271
MediaWiki\Rest\Handler\getResponseFactory
getResponseFactory()
Get the ResponseFactory which can be used to generate Response objects.
Definition
Handler.php:365
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 Oct 9 2024 13:24:59 for MediaWiki by
1.10.0