Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
33.33% covered (danger)
33.33%
5 / 15
28.57% covered (danger)
28.57%
2 / 7
CRAP
0.00% covered (danger)
0.00%
0 / 1
ApiReadingListsSetup
33.33% covered (danger)
33.33%
5 / 15
28.57% covered (danger)
28.57%
2 / 7
21.52
0.00% covered (danger)
0.00%
0 / 1
 execute
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 getAllowedParams
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getHelpUrls
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 getExamplesMessages
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 isWriteMode
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 mustBePosted
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 isInternal
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace MediaWiki\Extension\ReadingLists\Api;
4
5use ApiBase;
6
7/**
8 * API module for all write operations.
9 * Each operation (command) is implemented as a submodule.
10 */
11class ApiReadingListsSetup extends ApiBase {
12
13    use ApiTrait;
14
15    /** @var string API module prefix */
16    private static $prefix = '';
17
18    /**
19     * Entry point for executing the module
20     * @inheritDoc
21     */
22    public function execute() {
23        $list = $this->getReadingListRepository( $this->getUser() )->setupForUser();
24        $listData = $this->getListFromRow( $list );
25        $this->getResult()->addValue( null, $this->getModuleName(),
26            [ 'list' => $listData ] );
27    }
28
29    /**
30     * @inheritDoc
31     */
32    protected function getAllowedParams() {
33        return [];
34    }
35
36    /**
37     * @inheritDoc
38     */
39    public function getHelpUrls() {
40        return [
41            'https://www.mediawiki.org/wiki/Special:MyLanguage/Extension:ReadingLists#API',
42        ];
43    }
44
45    /**
46     * @inheritDoc
47     */
48    protected function getExamplesMessages() {
49        return [
50            'action=readinglists&command=setup&token=123ABC'
51                => 'apihelp-readinglists+setup-example-1',
52        ];
53    }
54
55    // The parent module already enforces these but they make documentation nicer.
56
57    /**
58     * @inheritDoc
59     */
60    public function isWriteMode() {
61        return true;
62    }
63
64    /**
65     * @inheritDoc
66     */
67    public function mustBePosted() {
68        return true;
69    }
70
71    /**
72     * @inheritDoc
73     */
74    public function isInternal() {
75        // ReadingLists API is still experimental
76        return true;
77    }
78
79}