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