Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 37
0.00% covered (danger)
0.00%
0 / 7
CRAP
0.00% covered (danger)
0.00%
0 / 1
TopicRenamedPresentationModel
0.00% covered (danger)
0.00%
0 / 37
0.00% covered (danger)
0.00%
0 / 7
110
0.00% covered (danger)
0.00%
0 / 1
 getIconType
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 canRender
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
 getPrimaryLink
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getSecondaryLinks
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
6
 getHeaderMessageKey
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 getHeaderMessage
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
2
 getDiffLink
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Flow\Notifications;
4
5use Flow\Container;
6use Flow\UrlGenerator;
7use MediaWiki\Title\Title;
8
9class TopicRenamedPresentationModel extends FlowPresentationModel {
10
11    /** @inheritDoc */
12    public function getIconType() {
13        return 'flow-topic-renamed';
14    }
15
16    /** @inheritDoc */
17    public function canRender() {
18        return $this->hasTitle()
19            && $this->hasValidTopicWorkflowId();
20    }
21
22    /** @inheritDoc */
23    public function getPrimaryLink() {
24        return $this->getViewTopicLink();
25    }
26
27    /** @inheritDoc */
28    public function getSecondaryLinks() {
29        if ( $this->isUserTalkPage() ) {
30            $links = [
31                $this->getAgentLink(),
32                $this->getDiffLink(),
33            ];
34        } else {
35            $links = [
36                $this->getAgentLink(),
37                $this->getBoardByNewestLink(),
38                $this->getDiffLink( false ),
39            ];
40        }
41
42        $links[] = $this->getFlowUnwatchDynamicActionLink( true );
43
44        return $links;
45    }
46
47    /** @inheritDoc */
48    protected function getHeaderMessageKey() {
49        if ( $this->isUserTalkPage() ) {
50            return 'notification-header-flow-topic-renamed-user-talk';
51        } else {
52            return 'notification-header-flow-topic-renamed-v2';
53        }
54    }
55
56    /** @inheritDoc */
57    public function getHeaderMessage() {
58        $msg = $this->msg( $this->getHeaderMessageKey() );
59        $msg->plaintextParams( $this->getTopicTitle( 'old-subject' ) );
60        $msg->plaintextParams( $this->getTopicTitle( 'new-subject' ) );
61        $msg->params( $this->getViewingUserForGender() );
62        return $msg;
63    }
64
65    protected function getDiffLink( $prioritized = true ) {
66        /** @var UrlGenerator $urlGenerator */
67        $urlGenerator = Container::get( 'url_generator' );
68        $anchor = $urlGenerator->diffPostLink(
69            Title::newFromText( $this->event->getExtraParam( 'topic-workflow' )->getAlphadecimal(), NS_TOPIC ),
70            $this->event->getExtraParam( 'topic-workflow' ),
71            $this->event->getExtraParam( 'revision-id' )
72        );
73
74        return [
75            'url' => $anchor->getFullURL(),
76            'label' => $this->msg( 'notification-link-text-view-changes' )->params( $this->getViewingUserForGender() )->text(),
77            'description' => '',
78            'icon' => 'changes',
79            'prioritized' => $prioritized,
80        ];
81    }
82}