17 public function getIconType() {
18 return 'translate-mgs-icon';
21 public function getPrimaryLink() {
22 if ( $this->isBundled() ) {
26 $groupId = $this->
event->getExtraParam(
'groupId' );
28 'url' => SpecialPage::getTitleFor(
'Translate', $groupId )->getFullURL(),
29 'label' => $this->msg(
'notification-link-mgs-group-translate' )
30 ->params( $this->event->getExtraParam(
'groupLabel' ) )
34 public function getHeaderMessage() {
35 $msg = $this->msg(
'notification-header-message-group-subscription' );
36 $msg->params( $this->event->getExtraParam(
'groupLabel' ) );
40 public function getCompactHeaderMessageKey():
string {
41 $type = $this->
event->getType();
42 if ( $type ===
'translate-mgs-message-added' ) {
43 return 'notification-body-translate-mgs-message-added';
46 return parent::getCompactHeaderMessageKey();
49 public function getCompactHeaderMessage() {
50 $msg = $this->msg( $this->getCompactHeaderMessageKey() );
51 $msg->params( $this->getNumberOfChangedMessages( $this->event ) );
55 public function getBodyMessage() {
56 $type = $this->
event->getType();
57 if ( $type ===
'translate-mgs-message-added' ) {
58 if ( $this->isBundled() ) {
59 $events = $this->getBundledEvents();
60 $events[] = $this->event;
62 $events = [ $this->event ];
65 $addedOrUpdatedMessages = 0;
66 foreach ( $events as $event ) {
67 $addedOrUpdatedMessages += $this->getNumberOfChangedMessages( $event );
70 $msg = $this->msg(
'notification-body-translate-mgs-message-added' );
71 $msg->params( $addedOrUpdatedMessages );
76 private function getNumberOfChangedMessages( Event $event ):
int {
77 $changes = $event->getExtraParam(
'changes' );
79 $messageCount += count( $changes[MessageGroupSubscription::STATE_ADDED] ?? [] );
80 $messageCount += count( $changes[MessageGroupSubscription::STATE_UPDATED] ?? [] );