1
|
|
|
<?php |
2
|
|
|
namespace ApacheSolrForTypo3\Solr\Search; |
3
|
|
|
|
4
|
|
|
/*************************************************************** |
5
|
|
|
* Copyright notice |
6
|
|
|
* |
7
|
|
|
* (c) 2012-2015 Ingo Renner <[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 2 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
|
|
|
|
27
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\SearchRequest; |
28
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\SearchRequestAware; |
29
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\Statistics\StatisticsWriterProcessor; |
30
|
|
|
use ApacheSolrForTypo3\Solr\Query\Modifier\Statistics; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Statistics search component |
34
|
|
|
* |
35
|
|
|
* @author Ingo Renner <[email protected]> |
36
|
|
|
*/ |
37
|
|
|
class StatisticsComponent extends AbstractComponent implements SearchRequestAware |
38
|
|
|
{ |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var SearchRequest |
42
|
|
|
*/ |
43
|
|
|
protected $seachRequest; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Provides a component that is aware of the current SearchRequest |
47
|
|
|
* |
48
|
|
|
* @param SearchRequest $searchRequest |
49
|
|
|
*/ |
50
|
31 |
|
public function setSearchRequest(SearchRequest $searchRequest) |
51
|
|
|
{ |
52
|
31 |
|
$this->seachRequest = $searchRequest; |
53
|
31 |
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Initializes the search component. |
57
|
|
|
* |
58
|
|
|
*/ |
59
|
31 |
|
public function initializeSearchComponent() |
60
|
|
|
{ |
61
|
31 |
|
$solrConfiguration = $this->seachRequest->getContextTypoScriptConfiguration(); |
62
|
|
|
|
63
|
31 |
|
if ($solrConfiguration->getStatistics()) { |
64
|
27 |
|
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['afterSearch']['statistics'] = StatisticsWriterProcessor::class; |
65
|
|
|
// Only if addDebugData is enabled add Query modifier |
66
|
27 |
|
if ($solrConfiguration->getStatisticsAddDebugData()) { |
67
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['modifySearchQuery']['statistics'] = Statistics::class; |
68
|
|
|
} |
69
|
|
|
} |
70
|
31 |
|
} |
71
|
|
|
|
72
|
|
|
} |
73
|
|
|
|