Debian Codegraph @

skins/MinervaNeue/includes/Menu/PageActions/UserNamespaceOverflowBuilder.php

raw symbols SCIP
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21 namespace MediaWiki\Minerva\Menu\PageActions;
22
23 use MediaWiki\Context\IContextSource;
24 use MediaWiki\Minerva\LanguagesHelper;
25 use MediaWiki\Minerva\Menu\Entries\LanguageSelectorEntry;
26 use MediaWiki\Minerva\Menu\Group;
27 use MediaWiki\Minerva\Permissions\IMinervaPagePermissions;
28 use MediaWiki\Title\Title;
29
30 class UserNamespaceOverflowBuilder extends DefaultOverflowBuilder {
31
32 private IContextSource $context;
33 private LanguagesHelper $languagesHelper;
34
35 /**
36 * Initialize the overflow menu visible on the User namespace
37 * @param Title $title
38 * @param IContextSource $context
39 * @param IMinervaPagePermissions $permissions
40 * @param LanguagesHelper $languagesHelper
41 */
42 public function __construct(
43 Title $title,
44 IContextSource $context,
45 IMinervaPagePermissions $permissions,
46 LanguagesHelper $languagesHelper
47 ) {
48 $this->context = $context;
49 $this->languagesHelper = $languagesHelper;
50 parent::__construct( $title, $context, $permissions );
51 }
52
53 /**
54 * @inheritDoc
55 */
56 public function getGroup( array $toolbox, array $actions ): Group {
57 $group = parent::getGroup( $toolbox, $actions );
58
59 if ( $this->isAllowed( IMinervaPagePermissions::SWITCH_LANGUAGE ) ) {
60 $group->prependEntry( new LanguageSelectorEntry(
61 $this->getTitle(),
62 $this->languagesHelper->doesTitleHasLanguagesOrVariants(
63 $this->context->getOutput(),
64 $this->getTitle()
65 ),
66 $this->getMessageLocalizer(),
67 false,
68 // no additional classes
69 '',
70 'minerva-page-actions-language-switcher'
71 ) );
72 }
73
74 return $group;
75 }
76 }