Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| SpecialRedirectToSpecial | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| getRedirect | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Shortcuts to construct a special page alias. |
| 4 | * |
| 5 | * @license GPL-2.0-or-later |
| 6 | * @file |
| 7 | * @ingroup SpecialPage |
| 8 | */ |
| 9 | |
| 10 | namespace MediaWiki\SpecialPage; |
| 11 | |
| 12 | use MediaWiki\Title\Title; |
| 13 | |
| 14 | /** |
| 15 | * @stable to extend |
| 16 | * |
| 17 | * @ingroup SpecialPage |
| 18 | */ |
| 19 | abstract class SpecialRedirectToSpecial extends RedirectSpecialPage { |
| 20 | /** @var string Name of redirect target */ |
| 21 | protected $redirName; |
| 22 | |
| 23 | /** @var string|false Name of subpage of redirect target */ |
| 24 | protected $redirSubpage; |
| 25 | |
| 26 | /** |
| 27 | * @stable to call |
| 28 | * |
| 29 | * @param string $name |
| 30 | * @param string $redirName |
| 31 | * @param string|false $redirSubpage |
| 32 | * @param array $allowedRedirectParams |
| 33 | * @param array $addedRedirectParams |
| 34 | */ |
| 35 | public function __construct( |
| 36 | $name, $redirName, $redirSubpage = false, |
| 37 | $allowedRedirectParams = [], $addedRedirectParams = [] |
| 38 | ) { |
| 39 | parent::__construct( $name ); |
| 40 | $this->redirName = $redirName; |
| 41 | $this->redirSubpage = $redirSubpage; |
| 42 | $this->mAllowedRedirectParams = $allowedRedirectParams; |
| 43 | $this->mAddedRedirectParams = $addedRedirectParams; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * @param string|null $subpage |
| 48 | * @return Title|bool |
| 49 | */ |
| 50 | public function getRedirect( $subpage ) { |
| 51 | if ( $this->redirSubpage === false ) { |
| 52 | return SpecialPage::getTitleFor( $this->redirName, $subpage ); |
| 53 | } |
| 54 | |
| 55 | return SpecialPage::getTitleFor( $this->redirName, $this->redirSubpage ); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | /** @deprecated class alias since 1.41 */ |
| 60 | class_alias( SpecialRedirectToSpecial::class, 'SpecialRedirectToSpecial' ); |