|
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\Hierarchy\HierarchyPackage; |
|
18
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\OptionBased\Options\OptionsPackage; |
|
19
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\OptionBased\QueryGroup\QueryGroupPackage; |
|
20
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\RangeBased\DateRange\DateRangePackage; |
|
21
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\RangeBased\NumericRange\NumericRangePackage; |
|
22
|
|
|
use ApacheSolrForTypo3\Solr\System\Object\AbstractClassRegistry; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Class FacetRegistry |
|
26
|
|
|
* |
|
27
|
|
|
* @author Frans Saris <[email protected]> |
|
28
|
|
|
* @author Timo Hund <[email protected]> |
|
29
|
|
|
* @package ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets |
|
30
|
|
|
*/ |
|
31
|
|
|
class FacetRegistry extends AbstractClassRegistry |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* Array of available parser classNames |
|
35
|
|
|
* |
|
36
|
|
|
* @var array |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $classMap = [ |
|
39
|
|
|
'options' => OptionsPackage::class, |
|
40
|
|
|
'hierarchy' => HierarchyPackage::class, |
|
41
|
|
|
'queryGroup' => QueryGroupPackage::class, |
|
42
|
|
|
'dateRange' => DateRangePackage::class, |
|
43
|
|
|
'numericRange' => NumericRangePackage::class, |
|
44
|
|
|
]; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Default parser className |
|
48
|
|
|
* |
|
49
|
|
|
* @var string |
|
50
|
|
|
*/ |
|
51
|
|
|
protected $defaultClass = OptionsPackage::class; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Get defaultParser |
|
55
|
|
|
* |
|
56
|
|
|
* @return string |
|
57
|
|
|
*/ |
|
58
|
|
|
public function getDefaultPackage() |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->defaultClass; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Set defaultParser |
|
65
|
|
|
* |
|
66
|
|
|
* @param string $defaultPackageClassName |
|
67
|
|
|
*/ |
|
68
|
1 |
|
public function setDefaultPackage($defaultPackageClassName) |
|
69
|
|
|
{ |
|
70
|
1 |
|
$this->defaultClass = $defaultPackageClassName; |
|
71
|
1 |
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Get registered parser classNames |
|
75
|
|
|
* |
|
76
|
|
|
* @return array |
|
77
|
|
|
*/ |
|
78
|
|
|
public function getPackages() |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->classMap; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param string $className |
|
85
|
|
|
* @param string $type |
|
86
|
|
|
* @throws \InvalidArgumentException |
|
87
|
|
|
*/ |
|
88
|
3 |
|
public function registerPackage($className, $type) |
|
89
|
|
|
{ |
|
90
|
3 |
|
return $this->register($className, $type, AbstractFacetPackage::class); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Get package |
|
95
|
|
|
* |
|
96
|
|
|
* @param string $type |
|
97
|
|
|
* @return AbstractFacetPackage |
|
98
|
|
|
* @throws InvalidFacetPackageException |
|
99
|
|
|
*/ |
|
100
|
50 |
|
public function getPackage($type) |
|
101
|
|
|
{ |
|
102
|
50 |
|
$instance = $this->getInstance($type); |
|
103
|
50 |
|
if (!$instance instanceof AbstractFacetPackage) { |
|
104
|
|
|
throw new InvalidFacetPackageException('Invalid class registered for ' . htmlspecialchars($type)); |
|
105
|
|
|
} |
|
106
|
50 |
|
$instance->setObjectManager($this->objectManager); |
|
107
|
50 |
|
return $instance; |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|