Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
EnhancedEchoEditUserTalkPresentationModel
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 3
56
0.00% covered (danger)
0.00%
0 / 1
 getPrimaryLink
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
6
 getBodyMessage
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
12
 jsonSerialize
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2/**
3 * Our override of the built-in Echo presentation model for user talk page notifications.
4 *
5 * @file
6 * @ingroup Extensions
7 * @license MIT
8 */
9
10namespace MediaWiki\Extension\DiscussionTools\Notifications;
11
12use EchoEditUserTalkPresentationModel;
13use MediaWiki\Language\RawMessage;
14use Message;
15use Wikimedia\Timestamp\TimestampException;
16
17class EnhancedEchoEditUserTalkPresentationModel extends EchoEditUserTalkPresentationModel {
18
19    use DiscussionToolsEventTrait;
20
21    /**
22     * @inheritDoc
23     */
24    public function getPrimaryLink() {
25        $linkInfo = parent::getPrimaryLink();
26        // For events enhanced by DiscussionTools: link to the individual comment
27        $link = $this->getCommentLink();
28        if ( $link ) {
29            $linkInfo['url'] = $link;
30        }
31        return $linkInfo;
32    }
33
34    /**
35     * @inheritDoc
36     */
37    public function getBodyMessage() {
38        if ( !$this->isBundled() ) {
39            // For events enhanced by DiscussionTools: add a text snippet
40            // (Echo can only do this for new sections, not for every comment)
41            $snippet = $this->getContentSnippet();
42            if ( $snippet ) {
43                return new RawMessage( '$1', [ Message::plaintextParam( $snippet ) ] );
44            }
45        }
46        return parent::getBodyMessage();
47    }
48
49    /**
50     * @inheritDoc
51     * @throws TimestampException
52     */
53    public function jsonSerialize(): array {
54        $array = parent::jsonSerialize();
55
56        $array['links']['legacyPrimary'] = $this->addMarkAsRead( parent::getPrimaryLink() ) ?: [];
57
58        return $array;
59    }
60}