Debian Codegraph @

skins/MinervaNeue/includes/Menu/Entries/AuthMenuEntry.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 */
17
18 namespace MediaWiki\Minerva\Menu\Entries;
19
20 use MediaWiki\User\UserIdentity;
21 use MessageLocalizer;
22
23 /**
24 * Model for a menu entry that represents log-in / profile+logout pair of links
25 */
26 final class AuthMenuEntry extends CompositeMenuEntry implements IProfileMenuEntry {
27 private ProfileMenuEntry $profileMenuEntry;
28
29 /**
30 * Initialize the Auth menu entry
31 *
32 * @param UserIdentity $user Currently logged in user/anon
33 * @param MessageLocalizer $messageLocalizer used for text translation
34 * @param array $authLinksQuery Mapping of URI query parameter names to values.
35 */
36 public function __construct(
37 UserIdentity $user,
38 MessageLocalizer $messageLocalizer,
39 array $authLinksQuery
40 ) {
41 $this->profileMenuEntry = new ProfileMenuEntry( $user );
42 $entries = $user->isRegistered()
43 ? [ $this->profileMenuEntry ]
44 : [ new LogInMenuEntry( $messageLocalizer, $authLinksQuery ) ];
45 parent::__construct( $entries );
46 }
47
48 /**
49 * @inheritDoc
50 */
51 public function getName(): string {
52 return 'auth';
53 }
54
55 /**
56 * @inheritDoc
57 */
58 public function overrideProfileURL(
59 $customURL, $customLabel = null, $trackingCode = null
60 ): self {
61 $this->profileMenuEntry->overrideProfileURL( $customURL, $customLabel, $trackingCode );
62 return $this;
63 }
64 }