Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
MappingDump
0.00% covered (danger)
0.00%
0 / 15
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 / 10
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 MappingDump 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( null ) as $index ) {
33            $mapping = $conn->getIndex( $indexPrefix, $index )->getMapping();
34            $this->getResult()->addValue( null, $index, $mapping );
35        }
36        if ( $this->getSearchConfig()->isCompletionSuggesterEnabled() ) {
37            $index = $conn->getIndex( $indexPrefix, Connection::TITLE_SUGGEST_INDEX_SUFFIX );
38            if ( $index->exists() ) {
39                $mapping = $index->getMapping();
40                $this->getResult()->addValue( null, Connection::TITLE_SUGGEST_INDEX_SUFFIX, $mapping );
41            }
42        }
43    }
44
45    public function getAllowedParams() {
46        return [];
47    }
48
49    /**
50     * @see ApiBase::getExamplesMessages
51     * @return array
52     */
53    protected function getExamplesMessages() {
54        return [
55            'action=cirrus-mapping-dump' =>
56                'apihelp-cirrus-mapping-dump-example'
57        ];
58    }
59
60}