Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| RedirectException | |
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getTarget | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 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 | public function getTarget(): string { |
| 35 | return $this->target; |
| 36 | } |
| 37 | } |