Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
SubpageLinkRecommendationProvider | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
createRecommendation | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments\NewcomerTasks\AddLink; |
4 | |
5 | use GrowthExperiments\NewcomerTasks\SubpageRecommendationProvider; |
6 | use GrowthExperiments\NewcomerTasks\TaskType\LinkRecommendationTaskType; |
7 | use GrowthExperiments\NewcomerTasks\TaskType\TaskType; |
8 | use MediaWiki\Title\Title; |
9 | use StatusValue; |
10 | |
11 | /** |
12 | * Enable by adding the following to LocalSettings.php or a similar location: |
13 | * $class = \GrowthExperiments\NewcomerTasks\AddLink\SubpageLinkRecommendationProvider::class; |
14 | * $wgHooks['MediaWikiServices'][] = "$class::onMediaWikiServices"; |
15 | * $wgHooks['ContentHandlerDefaultModelFor'][] = "$class::onContentHandlerDefaultModelFor"; |
16 | * |
17 | * @inheritDoc |
18 | */ |
19 | class SubpageLinkRecommendationProvider |
20 | extends SubpageRecommendationProvider |
21 | implements LinkRecommendationProvider |
22 | { |
23 | /** @inheritDoc */ |
24 | protected static $subpageName = 'addlink'; |
25 | |
26 | /** @inheritDoc */ |
27 | protected static $serviceName = 'GrowthExperimentsLinkRecommendationProvider'; |
28 | |
29 | /** @inheritDoc */ |
30 | protected static $recommendationTaskTypeClass = LinkRecommendationTaskType::class; |
31 | |
32 | /** |
33 | * @inheritDoc |
34 | * @return LinkRecommendation|StatusValue |
35 | */ |
36 | public function createRecommendation( |
37 | Title $title, |
38 | TaskType $taskType, |
39 | array $data, |
40 | array $suggestionFilters = [] |
41 | ) { |
42 | return new LinkRecommendation( |
43 | $title, |
44 | $title->getArticleID(), |
45 | $title->getLatestRevID(), |
46 | LinkRecommendation::getLinksFromArray( $data['links'] ), |
47 | // We don't really need the meta field for subpage provider, so provide |
48 | // a fallback if not set |
49 | LinkRecommendation::getMetadataFromArray( $data['meta'] ?? [] ) |
50 | ); |
51 | } |
52 | |
53 | } |