Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
RecentChangeNotification
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 6
42
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 getRecentChange
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getPageStatus
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getSource
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 isUserTalkNotification
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 isWatchlistNotification
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * @license GPL-2.0-or-later
4 * @file
5 */
6
7namespace MediaWiki\RecentChanges;
8
9use MediaWiki\Notification\Types\WikiNotification;
10use MediaWiki\Page\PageIdentity;
11use MediaWiki\User\UserIdentity;
12
13/**
14 * Notification representing a Recent change. Used as base to transport Watchlist, UserTalk and
15 * Administrator recent changes notifications
16 *
17 * @newable
18 * @since 1.45
19 */
20class RecentChangeNotification extends WikiNotification {
21
22    public const TYPE = 'mediawiki.recent_change';
23
24    public const TALK_NOTIFICATION = 'talk';
25    public const ADMIN_NOTIFICATION = 'admin';
26    public const WATCHLIST_NOTIFICATION = 'watchlist';
27
28    private RecentChange $recentChange;
29    private string $pageStatus;
30    private string $source;
31
32    /**
33     * @param UserIdentity $editor
34     * @param PageIdentity $title
35     * @param RecentChange $recentChange
36     * @param string $pageStatus the Page status from RecentChange, this change is not persisted
37     * @param string $source one of types talk, admin or watchlist
38     */
39    public function __construct(
40        UserIdentity $editor,
41        PageIdentity $title,
42        RecentChange $recentChange,
43        string $pageStatus,
44        string $source
45    ) {
46        parent::__construct( self::TYPE, $title, $editor );
47        $this->source = $source;
48        $this->pageStatus  = $pageStatus;
49        $this->recentChange = $recentChange;
50    }
51
52    public function getRecentChange(): RecentChange {
53        return $this->recentChange;
54    }
55
56    /**
57     * Retrieve page state, one of:
58     * [ 'deleted', 'created', 'moved', 'restored', 'changed' ]
59     */
60    public function getPageStatus(): string {
61        return $this->pageStatus;
62    }
63
64    /**
65     * What is the notification source, is it a User Talk change, Watchlist notification or
66     * an admin notification ( Users loaded from UsersNotifiedOnAllChanges )
67     * @return string
68     */
69    public function getSource(): string {
70        return $this->source;
71    }
72
73    public function isUserTalkNotification(): bool {
74        return $this->source === self::TALK_NOTIFICATION;
75    }
76
77    public function isWatchlistNotification(): bool {
78        return $this->source === self::WATCHLIST_NOTIFICATION;
79    }
80
81}
82
83/** @deprecated class alias since 1.45 */
84class_alias( RecentChangeNotification::class, 'MediaWiki\\Watchlist\\RecentChangeNotification' );