1 | <?php |
||
36 | class Faceting implements ParameterBuilder |
||
37 | { |
||
38 | /** |
||
39 | * @var bool |
||
40 | */ |
||
41 | protected $isEnabled = false; |
||
42 | |||
43 | /** |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $sorting = ''; |
||
47 | |||
48 | /** |
||
49 | * @var int |
||
50 | */ |
||
51 | protected $minCount = 1; |
||
52 | |||
53 | /** |
||
54 | * @var |
||
55 | */ |
||
56 | protected $limit = 10; |
||
57 | |||
58 | /** |
||
59 | * @var array |
||
60 | */ |
||
61 | protected $fields = []; |
||
62 | |||
63 | /** |
||
64 | * @var array |
||
65 | */ |
||
66 | protected $additionalParameters = []; |
||
67 | |||
68 | /** |
||
69 | * Faceting constructor. |
||
70 | * |
||
71 | * private constructor should only be created with the from* methods |
||
72 | * |
||
73 | * @param bool $isEnabled |
||
74 | * @param string $sorting |
||
75 | * @param int $minCount |
||
76 | * @param int $limit |
||
77 | * @param array $fields |
||
78 | * @param array $additionalParameters |
||
79 | */ |
||
80 | private function __construct($isEnabled, $sorting = '', $minCount = 1, $limit = 10, $fields = [], $additionalParameters = []) |
||
89 | |||
90 | /** |
||
91 | * @return boolean |
||
92 | */ |
||
93 | public function getIsEnabled() |
||
97 | |||
98 | /** |
||
99 | * @param boolean $isEnabled |
||
100 | */ |
||
101 | public function setIsEnabled($isEnabled) |
||
105 | |||
106 | /** |
||
107 | * @return string |
||
108 | */ |
||
109 | public function getSorting() |
||
113 | |||
114 | /** |
||
115 | * @param string $sorting |
||
116 | */ |
||
117 | public function setSorting($sorting) |
||
121 | |||
122 | /** |
||
123 | * @return int |
||
124 | */ |
||
125 | public function getMinCount() |
||
129 | |||
130 | /** |
||
131 | * @param int $minCount |
||
132 | */ |
||
133 | public function setMinCount($minCount) |
||
137 | |||
138 | /** |
||
139 | * @return mixed |
||
140 | */ |
||
141 | public function getLimit() |
||
145 | |||
146 | /** |
||
147 | * @param mixed $limit |
||
148 | */ |
||
149 | public function setLimit($limit) |
||
153 | |||
154 | /** |
||
155 | * @return array |
||
156 | */ |
||
157 | public function getFields() |
||
161 | |||
162 | /** |
||
163 | * @param array $fields |
||
164 | */ |
||
165 | public function setFields(array $fields) |
||
169 | |||
170 | /** |
||
171 | * @param string $fieldName |
||
172 | */ |
||
173 | public function addField($fieldName) |
||
177 | |||
178 | /** |
||
179 | * @return array |
||
180 | */ |
||
181 | public function getAdditionalParameters(): array |
||
185 | |||
186 | /** |
||
187 | * @param array $additionalParameters |
||
188 | */ |
||
189 | public function setAdditionalParameters(array $additionalParameters) |
||
193 | |||
194 | /** |
||
195 | * @param array $value |
||
196 | */ |
||
197 | public function addAdditionalParameter($key, $value) |
||
201 | |||
202 | /** |
||
203 | * @return array |
||
204 | */ |
||
205 | public function build() |
||
226 | |||
227 | /** |
||
228 | * Reads the facet sorting configuration and applies it to the queryParameters. |
||
229 | * |
||
230 | * @return array |
||
231 | */ |
||
232 | protected function applySorting(array $facetParameters) |
||
249 | |||
250 | /** |
||
251 | * @param TypoScriptConfiguration $solrConfiguration |
||
252 | * @return Faceting |
||
253 | */ |
||
254 | public static function fromTypoScriptConfiguration(TypoScriptConfiguration $solrConfiguration) |
||
267 | |||
268 | } |