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