Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
27 / 27 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
RevisionHandler | |
100.00% |
27 / 27 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
1 | |||
factory | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
1 | |||
getRevision | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace MediaWiki\IPInfo\Rest\Handler; |
4 | |
5 | use JobQueueGroup; |
6 | use MediaWiki\IPInfo\InfoManager; |
7 | use MediaWiki\IPInfo\Rest\Presenter\DefaultPresenter; |
8 | use MediaWiki\IPInfo\TempUserIPLookup; |
9 | use MediaWiki\Languages\LanguageFallback; |
10 | use MediaWiki\Permissions\PermissionManager; |
11 | use MediaWiki\Registration\ExtensionRegistry; |
12 | use MediaWiki\Revision\RevisionLookup; |
13 | use MediaWiki\Revision\RevisionRecord; |
14 | use MediaWiki\User\Options\UserOptionsLookup; |
15 | use MediaWiki\User\UserFactory; |
16 | use MediaWiki\User\UserIdentityUtils; |
17 | |
18 | class RevisionHandler extends AbstractRevisionHandler { |
19 | |
20 | private RevisionLookup $revisionLookup; |
21 | |
22 | public function __construct( |
23 | InfoManager $infoManager, |
24 | RevisionLookup $revisionLookup, |
25 | PermissionManager $permissionManager, |
26 | UserOptionsLookup $userOptionsLookup, |
27 | UserFactory $userFactory, |
28 | DefaultPresenter $presenter, |
29 | JobQueueGroup $jobQueueGroup, |
30 | LanguageFallback $languageFallback, |
31 | UserIdentityUtils $userIdentityUtils, |
32 | TempUserIPLookup $tempUserIPLookup, |
33 | ExtensionRegistry $extensionRegistry |
34 | ) { |
35 | parent::__construct( |
36 | $infoManager, |
37 | $permissionManager, |
38 | $userOptionsLookup, |
39 | $userFactory, |
40 | $presenter, |
41 | $jobQueueGroup, |
42 | $languageFallback, |
43 | $userIdentityUtils, |
44 | $tempUserIPLookup, |
45 | $extensionRegistry |
46 | ); |
47 | $this->revisionLookup = $revisionLookup; |
48 | } |
49 | |
50 | public static function factory( |
51 | InfoManager $infoManager, |
52 | RevisionLookup $revisionLookup, |
53 | PermissionManager $permissionManager, |
54 | UserOptionsLookup $userOptionsLookup, |
55 | UserFactory $userFactory, |
56 | JobQueueGroup $jobQueueGroup, |
57 | LanguageFallback $languageFallback, |
58 | UserIdentityUtils $userIdentityUtils, |
59 | TempUserIPLookup $tempUserIPLookup, |
60 | ?ExtensionRegistry $extensionRegistry = null |
61 | ): self { |
62 | return new self( |
63 | $infoManager, |
64 | $revisionLookup, |
65 | $permissionManager, |
66 | $userOptionsLookup, |
67 | $userFactory, |
68 | new DefaultPresenter( $permissionManager ), |
69 | $jobQueueGroup, |
70 | $languageFallback, |
71 | $userIdentityUtils, |
72 | $tempUserIPLookup, |
73 | $extensionRegistry ?? ExtensionRegistry::getInstance() |
74 | ); |
75 | } |
76 | |
77 | /** @inheritDoc */ |
78 | protected function getRevision( int $id ): ?RevisionRecord { |
79 | return $this->revisionLookup->getRevisionById( $id ); |
80 | } |
81 | } |