Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
FlaggedRevsHookRunner
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 onRevisionFromEditComplete
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onFlaggedRevsRevisionReviewFormAfterDoSubmit
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onFlaggedRevsStabilitySettingsChanged
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3use MediaWiki\Extension\FlaggedRevs\Backend\Hook\FlaggedRevsStabilitySettingsChangedHook;
4use MediaWiki\HookContainer\HookContainer;
5use MediaWiki\Page\Hook\RevisionFromEditCompleteHook;
6use MediaWiki\Revision\RevisionRecord;
7use MediaWiki\User\UserIdentity;
8
9/**
10 * Handle running FlaggedRevs's hooks
11 * @author DannyS712
12 */
13class FlaggedRevsHookRunner implements
14    RevisionFromEditCompleteHook,
15    FlaggedRevsRevisionReviewFormAfterDoSubmitHook,
16    FlaggedRevsStabilitySettingsChangedHook
17{
18
19    /** @var HookContainer */
20    private $hookContainer;
21
22    /**
23     * @param HookContainer $hookContainer
24     */
25    public function __construct( HookContainer $hookContainer ) {
26        $this->hookContainer = $hookContainer;
27    }
28
29    /**
30     * @note Core hook that is run
31     *
32     * @param WikiPage $wikiPage WikiPage edited
33     * @param RevisionRecord $rev New revision
34     * @param int|bool $originalRevId If the edit restores or repeats an earlier revision (such as a
35     *   rollback or a null revision), the ID of that earlier revision. False otherwise.
36     *   (Used to be called $baseID.)
37     * @param UserIdentity $user Editing user
38     * @param string[] &$tags Tags to apply to the edit and recent change. This is empty, and
39     *   replacement is ignored, in the case of import or page move
40     */
41    public function onRevisionFromEditComplete( $wikiPage, $rev, $originalRevId,
42        $user, &$tags
43    ) {
44        $this->hookContainer->run(
45            'RevisionFromEditComplete',
46            [ $wikiPage, $rev, $originalRevId, $user, &$tags ]
47        );
48    }
49
50    /**
51     * @param RevisionReviewForm $form
52     * @param string|bool $status
53     */
54    public function onFlaggedRevsRevisionReviewFormAfterDoSubmit( $form, $status ) {
55        $this->hookContainer->run(
56            'FlaggedRevsRevisionReviewFormAfterDoSubmit',
57            [ $form, $status ]
58        );
59    }
60
61    /** @inheritDoc */
62    public function onFlaggedRevsStabilitySettingsChanged( $title, $newStabilitySettings, $userIdentity, $reason ) {
63        $this->hookContainer->run(
64            'FlaggedRevsStabilitySettingsChanged',
65            [ $title, $newStabilitySettings, $userIdentity, $reason ]
66        );
67    }
68}