Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 36 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
NewsletterLogger | |
0.00% |
0 / 36 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
logPublisherAdded | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
logPublisherRemoved | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
logNewsletterAdded | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
logNewIssue | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\Newsletter\Logging; |
4 | |
5 | use ManualLogEntry; |
6 | use MediaWiki\Context\RequestContext; |
7 | use MediaWiki\Extension\Newsletter\Newsletter; |
8 | use MediaWiki\SpecialPage\SpecialPage; |
9 | use MediaWiki\Title\Title; |
10 | use MediaWiki\User\User; |
11 | |
12 | /** |
13 | * @license GPL-2.0-or-later |
14 | * @author Tyler Romeo |
15 | * @author Addshore |
16 | */ |
17 | class NewsletterLogger { |
18 | |
19 | public function logPublisherAdded( Newsletter $newsletter, User $user ) { |
20 | $log = new ManualLogEntry( 'newsletter', 'publisher-added' ); |
21 | $log->setPerformer( RequestContext::getMain()->getUser() ); |
22 | $log->setTarget( $user->getUserPage() ); |
23 | $log->setParameters( [ |
24 | '4:newsletter-link:nl_id' => "{$newsletter->getId()}:{$newsletter->getName()}" |
25 | ] ); |
26 | $log->setRelations( [ 'nl_id' => $newsletter->getId() ] ); |
27 | $log->publish( $log->insert() ); |
28 | } |
29 | |
30 | public function logPublisherRemoved( Newsletter $newsletter, User $user ) { |
31 | $log = new ManualLogEntry( 'newsletter', 'publisher-removed' ); |
32 | $log->setPerformer( RequestContext::getMain()->getUser() ); |
33 | $log->setTarget( $user->getUserPage() ); |
34 | $log->setParameters( [ |
35 | '4:newsletter-link:nl_id' => "{$newsletter->getId()}:{$newsletter->getName()}" |
36 | ] ); |
37 | $log->setRelations( [ 'nl_id' => $newsletter->getId() ] ); |
38 | $log->publish( $log->insert() ); |
39 | } |
40 | |
41 | public function logNewsletterAdded( Newsletter $newsletter ) { |
42 | $id = $newsletter->getId(); |
43 | $log = new ManualLogEntry( 'newsletter', 'newsletter-added' ); |
44 | $log->setPerformer( RequestContext::getMain()->getUser() ); |
45 | $log->setTarget( SpecialPage::getTitleFor( 'Newsletter', (string)$id ) ); |
46 | $log->setParameters( [ |
47 | '4:newsletter-link:nl_id' => "$id:{$newsletter->getName()}" |
48 | ] ); |
49 | $log->setRelations( [ 'nl_id' => $id ] ); |
50 | $log->publish( $log->insert() ); |
51 | } |
52 | |
53 | public function logNewIssue( |
54 | User $publisher, |
55 | Newsletter $newsletter, |
56 | Title $issueTitle, |
57 | $issueId, |
58 | $comment |
59 | ) { |
60 | $log = new ManualLogEntry( 'newsletter', 'issue-added' ); |
61 | $log->setPerformer( $publisher ); |
62 | $log->setTarget( SpecialPage::getTitleFor( 'Newsletter', (string)$newsletter->getId() ) ); |
63 | $log->setParameters( [ |
64 | '4:newsletter-link:nl_id' => "{$newsletter->getId()}:{$newsletter->getName()}", |
65 | '5::nli_issue_id' => $issueId, |
66 | '6::nl_issue_title' => $issueTitle->getPrefixedText(), |
67 | ] ); |
68 | $log->setComment( $comment ); |
69 | $log->setRelations( [ 'nl_id' => $newsletter->getId() ] ); |
70 | $log->publish( $log->insert() ); |
71 | } |
72 | |
73 | } |