1
|
|
|
<?php |
2
|
|
|
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\OptionBased\QueryGroup; |
3
|
|
|
/* |
4
|
|
|
* This file is part of the TYPO3 CMS project. |
5
|
|
|
* |
6
|
|
|
* It is free software; you can redistribute it and/or modify it under |
7
|
|
|
* the terms of the GNU General Public License, either version 2 |
8
|
|
|
* of the License, or any later version. |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please read the |
11
|
|
|
* LICENSE.txt file that was distributed with this source code. |
12
|
|
|
* |
13
|
|
|
* The TYPO3 project - inspiring people to share! |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\FacetQueryBuilderInterface; |
17
|
|
|
use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration; |
18
|
|
|
|
19
|
|
|
class QueryGroupFacetQueryBuilder implements FacetQueryBuilderInterface { |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @param string $facetName |
23
|
|
|
* @param TypoScriptConfiguration $configuration |
24
|
|
|
* @return array |
25
|
|
|
*/ |
26
|
|
|
public function build($facetName, TypoScriptConfiguration $configuration) |
27
|
|
|
{ |
28
|
|
|
$facetParameters = []; |
29
|
|
|
$facetConfiguration = $configuration->getSearchFacetingFacetByName($facetName); |
30
|
|
|
|
31
|
|
|
foreach ($facetConfiguration['queryGroup.'] as $queryName => $queryConfiguration) { |
32
|
|
|
$tag = ''; |
33
|
|
|
if ($configuration->getSearchFacetingKeepAllFacetsOnSelection()) { |
34
|
|
|
// TODO This code is duplicated from "Query/Modifier/Faceting.php" |
35
|
|
|
// Eventually the "exclude fields" should get passed to this method beforehand instead |
36
|
|
|
// of generating them in each different "buildFacetParameters" implementation |
37
|
|
|
$facets = []; |
38
|
|
|
foreach ($configuration->getSearchFacetingFacets() as $facet) { |
39
|
|
|
$facets[] = $facet['field']; |
40
|
|
|
} |
41
|
|
|
$tag = '{!ex=' . implode(',', $facets) . '}'; |
42
|
|
|
} elseif ($facetConfiguration['keepAllOptionsOnSelection'] == 1) { |
43
|
|
|
$tag = '{!ex=' . $facetConfiguration['field'] . '}'; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
$facetParameters['facet.query'][] = $tag . $facetConfiguration['field'] . ':' . $queryConfiguration['query']; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
return $facetParameters; |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|