Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
FallbackSlotRoleHandler
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isAllowedOn
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isAllowedModel
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getOutputLayoutHints
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * This file is part of MediaWiki.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
23namespace MediaWiki\Revision;
24
25use MediaWiki\Linker\LinkTarget;
26use MediaWiki\Page\PageIdentity;
27
28/**
29 * A SlotRoleHandler for providing basic functionality for undefined slot roles.
30 *
31 * This class is intended to be used when encountering slots with a role that used to be defined
32 * by an extension, but no longer is backed by hany specific handler, since the extension in
33 * question has been uninstalled. It may also be used for pages imported from another wiki.
34 *
35 * @since 1.33
36 */
37class FallbackSlotRoleHandler extends SlotRoleHandler {
38
39    public function __construct( $role ) {
40        parent::__construct( $role, CONTENT_MODEL_UNKNOWN );
41    }
42
43    /**
44     * @param LinkTarget $page
45     *
46     * @return bool Always false, to prevent undefined slots from being used in new revisions.
47     */
48    public function isAllowedOn( LinkTarget $page ) {
49        return false;
50    }
51
52    /**
53     * @param string $model
54     * @param PageIdentity $page
55     *
56     * @return bool Always false, to prevent undefined slots from being used for
57     *         arbitrary content.
58     */
59    public function isAllowedModel( $model, PageIdentity $page ) {
60        return false;
61    }
62
63    public function getOutputLayoutHints() {
64        // TODO: should we return [ 'display' => 'none'] here, causing undefined slots
65        // to be hidden? We'd still need some place to surface the content of such
66        // slots, see T209923.
67
68        return parent::getOutputLayoutHints();
69    }
70
71}