Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| FallbackSlotRoleHandler | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isAllowedOn | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isAllowedModel | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getOutputLayoutHints | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * This file is part of MediaWiki. |
| 4 | * |
| 5 | * @license GPL-2.0-or-later |
| 6 | * @file |
| 7 | */ |
| 8 | |
| 9 | namespace MediaWiki\Revision; |
| 10 | |
| 11 | use MediaWiki\Linker\LinkTarget; |
| 12 | use MediaWiki\Page\PageIdentity; |
| 13 | |
| 14 | /** |
| 15 | * A SlotRoleHandler for providing basic functionality for undefined slot roles. |
| 16 | * |
| 17 | * This class is intended to be used when encountering slots with a role that used to be defined |
| 18 | * by an extension, but no longer is backed by many specific handler, since the extension in |
| 19 | * question has been uninstalled. It may also be used for pages imported from another wiki. |
| 20 | * |
| 21 | * @since 1.33 |
| 22 | */ |
| 23 | class FallbackSlotRoleHandler extends SlotRoleHandler { |
| 24 | |
| 25 | public function __construct( string $role ) { |
| 26 | parent::__construct( $role, CONTENT_MODEL_UNKNOWN ); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * @param LinkTarget $page |
| 31 | * |
| 32 | * @return bool Always false, to prevent undefined slots from being used in new revisions. |
| 33 | */ |
| 34 | public function isAllowedOn( LinkTarget $page ) { |
| 35 | return false; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * @param string $model |
| 40 | * @param PageIdentity $page |
| 41 | * |
| 42 | * @return bool Always false, to prevent undefined slots from being used for |
| 43 | * arbitrary content. |
| 44 | */ |
| 45 | public function isAllowedModel( $model, PageIdentity $page ) { |
| 46 | return false; |
| 47 | } |
| 48 | |
| 49 | /** @inheritDoc */ |
| 50 | public function getOutputLayoutHints() { |
| 51 | // TODO: should we return [ 'display' => 'none'] here, causing undefined slots |
| 52 | // to be hidden? We'd still need some place to surface the content of such |
| 53 | // slots, see T209923. |
| 54 | |
| 55 | return parent::getOutputLayoutHints(); |
| 56 | } |
| 57 | |
| 58 | } |