Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 23 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| SettingsDump | |
0.00% |
0 / 23 |
|
0.00% |
0 / 4 |
56 | |
0.00% |
0 / 1 |
| execute | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
20 | |||
| getAllowedParams | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isInternal | |
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 | * @license GPL-2.0-or-later |
| 13 | */ |
| 14 | class SettingsDump extends ApiBase { |
| 15 | use ApiTrait; |
| 16 | |
| 17 | public function execute() { |
| 18 | $conn = $this->getCirrusConnection(); |
| 19 | $indexPrefix = $this->getSearchConfig()->get( SearchConfig::INDEX_BASE_NAME ); |
| 20 | foreach ( $conn->getAllIndexSuffixes() as $index ) { |
| 21 | $this->getResult()->addValue( |
| 22 | [ $index, 'page' ], |
| 23 | 'index', |
| 24 | $conn->getIndex( $indexPrefix, $index )->getSettings()->get() |
| 25 | ); |
| 26 | } |
| 27 | if ( $this->getSearchConfig()->isCompletionSuggesterEnabled() ) { |
| 28 | $index = $conn->getIndex( $indexPrefix, Connection::TITLE_SUGGEST_INDEX_SUFFIX ); |
| 29 | if ( $index->exists() ) { |
| 30 | $mapping = $index->getSettings()->get(); |
| 31 | $this->getResult()->addValue( |
| 32 | [ Connection::TITLE_SUGGEST_INDEX_SUFFIX, Connection::TITLE_SUGGEST_INDEX_SUFFIX ], |
| 33 | 'index', |
| 34 | $mapping |
| 35 | ); |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | /** @inheritDoc */ |
| 41 | public function getAllowedParams() { |
| 42 | return []; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Mark as internal. This isn't meant to be used by normal api users |
| 47 | * @return bool |
| 48 | */ |
| 49 | public function isInternal() { |
| 50 | return true; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * @see ApiBase::getExamplesMessages |
| 55 | * @return array |
| 56 | */ |
| 57 | protected function getExamplesMessages() { |
| 58 | return [ |
| 59 | 'action=cirrus-settings-dump' => |
| 60 | 'apihelp-cirrus-settings-dump-example' |
| 61 | ]; |
| 62 | } |
| 63 | |
| 64 | } |