MediaWiki master
RedirectHandler.php
Go to the documentation of this file.
1<?php
2
4
9
14class 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}
Exceptions for config failures.
Base class for REST route handlers.
Definition Handler.php:23
getRequest()
Get the current request.
Definition Handler.php:318
getConfig()
Get the configuration array for the current route.
Definition Handler.php:340
getRouter()
Get the Router.
Definition Handler.php:257
getResponseFactory()
Get the ResponseFactory which can be used to generate Response objects.
Definition Handler.php:351
Copyright (C) 2011-2020 Wikimedia Foundation and others.