Debian Codegraph @

includes/Rest/RedirectException.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Rest;
4
5 /**
6 * This is an exception class that extends HttpException and will
7 * generate a redirect when handled. It is used when a redirect is
8 * treated as an exception output in your API, and you want to be able
9 * to throw it from wherever you are and immediately halt request
10 * processing.
11 *
12 * @newable
13 * @since 1.36
14 */
15 class RedirectException extends HttpException {
16
17 /**
18 * The redirect target (an absolute URL)
19 * @var string
20 */
21 private $target;
22
23 /**
24 * @stable to call
25 *
26 * @param int $code The HTTP status code (3xx) for this redirect
27 * @param string $target The redirect target (an absolute URL)
28 */
29 public function __construct( int $code, string $target ) {
30 parent::__construct( 'Redirect', $code );
31 $this->target = $target;
32 }
33
34 /**
35 * @return string
36 */
37 public function getTarget(): string {
38 return $this->target;
39 }
40 }