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