user = $user; } /** * @inheritDoc */ public function getName(): string { return 'profile'; } /** * @inheritDoc */ public function overrideProfileURL( $customURL, $customLabel = null, $trackingCode = null ): self { $this->customProfileURL = $customURL; $this->customProfileLabel = $customLabel; $this->profileTrackingCode = $trackingCode; return $this; } /** * @inheritDoc */ public function getCSSClasses(): array { return []; } /** * @inheritDoc */ public function getComponents(): array { $username = $this->user->getName(); return [ [ 'data-icon' => [ 'icon' => 'userAvatar-base20', ], 'label' => $this->customProfileLabel ?? $username, 'array-attributes' => [ [ 'key' => 'href', 'value' => $this->customProfileURL ?? Title::makeTitle( NS_USER, $username )->getLocalURL(), ], [ 'key' => 'data-event-name', 'value' => 'menu.' . ( $this->profileTrackingCode ?? self::DEFAULT_PROFILE_TRACKING_CODE ) ], ], 'classes' => 'menu__item--user', ] ]; } }