1 | <?php |
||
24 | class EchoNotificationsHandlers { |
||
25 | |||
26 | /** |
||
27 | * Type of notification |
||
28 | */ |
||
29 | const NOTIFICATION_TYPE = 'page-connection'; |
||
30 | |||
31 | /** |
||
32 | * @var RepoLinker |
||
33 | */ |
||
34 | private $repoLinker; |
||
35 | |||
36 | /** |
||
37 | * @var NamespaceChecker |
||
38 | */ |
||
39 | private $namespaceChecker; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | */ |
||
44 | private $siteId; |
||
45 | |||
46 | /** |
||
47 | * @var bool |
||
48 | */ |
||
49 | private $sendEchoNotification; |
||
50 | |||
51 | /** |
||
52 | * @var string |
||
53 | */ |
||
54 | private $repoSiteName; |
||
55 | |||
56 | /** |
||
57 | * @param RepoLinker $repoLinker |
||
58 | * @param NamespaceChecker $namespaceChecker |
||
59 | * @param string $siteId |
||
60 | * @param bool $sendEchoNotification |
||
61 | * @param string $repoSiteName |
||
62 | */ |
||
63 | public function __construct( |
||
76 | |||
77 | /** |
||
78 | * @return self |
||
79 | */ |
||
80 | public static function factory() { |
||
81 | $wikibaseClient = WikibaseClient::getDefaultInstance(); |
||
82 | $settings = $wikibaseClient->getSettings(); |
||
83 | |||
84 | return new self( |
||
85 | $wikibaseClient->newRepoLinker(), |
||
86 | $wikibaseClient->getNamespaceChecker(), |
||
87 | $settings->getSetting( 'siteGlobalID' ), |
||
88 | $settings->getSetting( 'sendEchoNotification' ), |
||
89 | $settings->getSetting( 'repoSiteName' ) |
||
90 | ); |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * Handler for EchoGetBundleRules hook |
||
95 | * @see https://www.mediawiki.org/wiki/Notifications/Developer_guide#Bundled_notifications |
||
96 | * |
||
97 | * @param EchoEvent $event |
||
98 | * @param string &$bundleString |
||
99 | */ |
||
100 | public static function onEchoGetBundleRules( EchoEvent $event, &$bundleString ) { |
||
105 | |||
106 | /** |
||
107 | * Handler for LocalUserCreated hook. |
||
108 | * @see https://www.mediawiki.org/wiki/Manual:Hooks/LocalUserCreated |
||
109 | * @param User $user User object that was created. |
||
110 | * @param bool $autocreated True when account was auto-created |
||
111 | */ |
||
112 | public static function onLocalUserCreated( User $user, $autocreated ) { |
||
116 | |||
117 | /** |
||
118 | * @param User $user |
||
119 | * @param bool $autocreated |
||
120 | */ |
||
121 | public function doLocalUserCreated( User $user, $autocreated ) { |
||
127 | |||
128 | /** |
||
129 | * Handler for WikibaseHandleChange hook |
||
130 | * @see doWikibaseHandleChange |
||
131 | * |
||
132 | * @param Change $change |
||
133 | */ |
||
134 | public static function onWikibaseHandleChange( Change $change ) { |
||
138 | |||
139 | /** |
||
140 | * @param Change $change |
||
141 | * |
||
142 | * @return bool |
||
143 | */ |
||
144 | public function doWikibaseHandleChange( Change $change ) { |
||
187 | |||
188 | /** |
||
189 | * Determines whether the change was a real sitelink addition |
||
190 | * and returns either title, or false |
||
191 | * |
||
192 | * @param DiffOp $siteLinkDiffOp |
||
193 | * |
||
194 | * @return Title|false |
||
195 | */ |
||
196 | private function getTitleForNotification( DiffOp $siteLinkDiffOp ) { |
||
235 | |||
236 | /** |
||
237 | * Whether it's reasonable to send a notification for the title |
||
238 | * |
||
239 | * @param Title $title |
||
240 | * |
||
241 | * @return bool |
||
242 | */ |
||
243 | private function canNotifyForTitle( Title $title ) { |
||
247 | |||
248 | } |
||
249 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.