Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 22 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
SettingsDump | |
0.00% |
0 / 22 |
|
0.00% |
0 / 3 |
42 | |
0.00% |
0 / 1 |
execute | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
20 | |||
getAllowedParams | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getExamplesMessages | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace CirrusSearch\Api; |
4 | |
5 | use CirrusSearch\Connection; |
6 | use CirrusSearch\SearchConfig; |
7 | use MediaWiki\Api\ApiBase; |
8 | |
9 | /** |
10 | * Dumps CirrusSearch mappings for easy viewing. |
11 | * |
12 | * This program is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License as published by |
14 | * the Free Software Foundation; either version 2 of the License, or |
15 | * (at your option) any later version. |
16 | * |
17 | * This program is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 | * GNU General Public License for more details. |
21 | * |
22 | * You should have received a copy of the GNU General Public License along |
23 | * with this program; if not, write to the Free Software Foundation, Inc., |
24 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
25 | * http://www.gnu.org/copyleft/gpl.html |
26 | */ |
27 | class SettingsDump extends ApiBase { |
28 | use ApiTrait; |
29 | |
30 | public function execute() { |
31 | $conn = $this->getCirrusConnection(); |
32 | $indexPrefix = $this->getSearchConfig()->get( SearchConfig::INDEX_BASE_NAME ); |
33 | foreach ( $conn->getAllIndexSuffixes() as $index ) { |
34 | $this->getResult()->addValue( |
35 | [ $index, 'page' ], |
36 | 'index', |
37 | $conn->getIndex( $indexPrefix, $index )->getSettings()->get() |
38 | ); |
39 | } |
40 | if ( $this->getSearchConfig()->isCompletionSuggesterEnabled() ) { |
41 | $index = $conn->getIndex( $indexPrefix, Connection::TITLE_SUGGEST_INDEX_SUFFIX ); |
42 | if ( $index->exists() ) { |
43 | $mapping = $index->getSettings()->get(); |
44 | $this->getResult()->addValue( |
45 | [ Connection::TITLE_SUGGEST_INDEX_SUFFIX, Connection::TITLE_SUGGEST_INDEX_SUFFIX ], |
46 | 'index', |
47 | $mapping |
48 | ); |
49 | } |
50 | } |
51 | } |
52 | |
53 | /** @inheritDoc */ |
54 | public function getAllowedParams() { |
55 | return []; |
56 | } |
57 | |
58 | /** |
59 | * @see ApiBase::getExamplesMessages |
60 | * @return array |
61 | */ |
62 | protected function getExamplesMessages() { |
63 | return [ |
64 | 'action=cirrus-settings-dump' => |
65 | 'apihelp-cirrus-settings-dump-example' |
66 | ]; |
67 | } |
68 | |
69 | } |