1
|
|
|
<?php |
2
|
|
|
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets; |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* This file is part of the TYPO3 CMS project. |
6
|
|
|
* |
7
|
|
|
* It is free software; you can redistribute it and/or modify it under |
8
|
|
|
* the terms of the GNU General Public License, either version 2 |
9
|
|
|
* of the License, or any later version. |
10
|
|
|
* |
11
|
|
|
* For the full copyright and license information, please read the |
12
|
|
|
* LICENSE.txt file that was distributed with this source code. |
13
|
|
|
* |
14
|
|
|
* The TYPO3 project - inspiring people to share! |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\OptionBased\QueryGroup\QueryGroupFacetQueryBuilder; |
18
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\RangeBased\DateRange\DateRangeFacetQueryBuilder; |
19
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\RangeBased\NumericRange\NumericRangeFacetQueryBuilder; |
20
|
|
|
use ApacheSolrForTypo3\Solr\System\Object\AbstractClassRegistry; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Class FacetUrlEncoderRegistry |
24
|
|
|
* |
25
|
|
|
* @author Frans Saris <[email protected]> |
26
|
|
|
* @author Timo Hund <[email protected]> |
27
|
|
|
* @package ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets |
28
|
|
|
*/ |
29
|
|
|
class FacetQueryBuilderRegistry extends AbstractClassRegistry |
30
|
|
|
{ |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Array of available encoder classNames |
34
|
|
|
* @var array |
35
|
|
|
*/ |
36
|
|
|
protected $classMap = [ |
37
|
|
|
'queryGroup' => QueryGroupFacetQueryBuilder::class, |
38
|
|
|
'dateRange' => DateRangeFacetQueryBuilder::class, |
39
|
|
|
'numericRange' => NumericRangeFacetQueryBuilder::class |
40
|
|
|
]; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Default parser className |
44
|
|
|
* |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
protected $defaultClass = DefaultFacetQueryBuilder::class; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Get queryBuilder |
51
|
|
|
* |
52
|
|
|
* @param string $type |
53
|
|
|
* @return FacetQueryBuilderInterface |
54
|
|
|
* @throws \Exception |
55
|
|
|
*/ |
56
|
28 |
|
public function getQueryBuilder($type) |
57
|
|
|
{ |
58
|
28 |
|
$instance = $this->getInstance($type); |
59
|
28 |
|
if(!$instance instanceof FacetQueryBuilderInterface) { |
60
|
|
|
throw new \Exception('Invalid class registered for ' . htmlspecialchars($type)); |
61
|
|
|
} |
62
|
28 |
|
return $instance; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|