1
|
|
|
<?php |
2
|
|
|
namespace ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder; |
3
|
|
|
|
4
|
|
|
/*************************************************************** |
5
|
|
|
* Copyright notice |
6
|
|
|
* |
7
|
|
|
* (c) 2017 <[email protected]> |
8
|
|
|
* All rights reserved |
9
|
|
|
* |
10
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
11
|
|
|
* 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 3 of the License, or |
14
|
|
|
* (at your option) any later version. |
15
|
|
|
* |
16
|
|
|
* The GNU General Public License can be found at |
17
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
18
|
|
|
* |
19
|
|
|
* This script is distributed in the hope that it will be useful, |
20
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
21
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22
|
|
|
* GNU General Public License for more details. |
23
|
|
|
* |
24
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
25
|
|
|
***************************************************************/ |
26
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\Query\Query; |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* The Debug ParameterProvider is responsible to build the solr query parameters |
31
|
|
|
* that are needed for the debugging. |
32
|
|
|
* |
33
|
|
|
* @package ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder |
34
|
|
|
*/ |
35
|
|
|
class Debug extends AbstractDeactivatableParameterBuilder implements ParameterBuilder |
36
|
|
|
{ |
37
|
|
|
/** |
38
|
|
|
* Debug constructor. |
39
|
|
|
* |
40
|
|
|
* @param bool $isEnabled |
41
|
|
|
*/ |
42
|
|
|
public function __construct($isEnabled) |
43
|
|
|
{ |
44
|
|
|
$this->isEnabled = $isEnabled; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param Query $query |
49
|
|
|
* @return Query |
50
|
|
|
*/ |
51
|
|
|
public function build(Query $query): Query |
52
|
|
|
{ |
53
|
|
|
if (!$this->isEnabled) { |
54
|
|
|
$query->getQueryParametersContainer()->removeMany(['debugQuery', 'echoParams']); |
55
|
|
|
return $query; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$query->getQueryParametersContainer()->merge(['debugQuery' => 'true', 'echoParams' => 'all']); |
59
|
|
|
return $query; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return Debug |
64
|
|
|
*/ |
65
|
|
|
public static function getEmpty() |
66
|
|
|
{ |
67
|
|
|
return new Debug(false); |
68
|
|
|
} |
69
|
|
|
} |