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
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Value object that represent a options facet. |
20
|
|
|
* |
21
|
|
|
* @author Frans Saris <[email protected]> |
22
|
|
|
* @author Timo Hund <[email protected]> |
23
|
|
|
* @package ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\OptionsFacet |
24
|
|
|
*/ |
25
|
|
|
abstract class AbstractFacet |
26
|
|
|
{ |
27
|
|
|
const TYPE_ABSTRACT = 'abstract'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* String |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
protected static $type = self::TYPE_ABSTRACT; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* The resultSet where this facet belongs to. |
37
|
|
|
* |
38
|
|
|
* @var SearchResultSet |
39
|
|
|
*/ |
40
|
|
|
protected $resultSet = null; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
protected $name; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var string |
49
|
|
|
*/ |
50
|
|
|
protected $field; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
protected $label; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var [] |
59
|
|
|
*/ |
60
|
|
|
protected $configuration; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var boolean |
64
|
|
|
*/ |
65
|
|
|
protected $isAvailable = false; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var bool |
69
|
|
|
*/ |
70
|
|
|
protected $isUsed = false; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* AbstractFacet constructor. |
74
|
|
|
* |
75
|
|
|
* @param SearchResultSet $resultSet |
76
|
|
|
* @param string $name |
77
|
|
|
* @param string $field |
78
|
|
|
* @param string $label |
79
|
|
|
* @param array $configuration Facet configuration passed from typoscript |
80
|
|
|
*/ |
81
|
|
|
public function __construct(SearchResultSet $resultSet, $name, $field, $label = '', array $configuration = []) |
82
|
|
|
{ |
83
|
|
|
$this->resultSet = $resultSet; |
84
|
|
|
$this->name = $name; |
85
|
|
|
$this->field = $field; |
86
|
|
|
$this->label = $label; |
87
|
|
|
$this->configuration = $configuration; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Get name |
92
|
|
|
* |
93
|
|
|
* @return string |
94
|
|
|
*/ |
95
|
|
|
public function getName() |
96
|
|
|
{ |
97
|
|
|
return $this->name; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Get solr field name |
102
|
|
|
* |
103
|
|
|
* @return string |
104
|
|
|
*/ |
105
|
|
|
public function getField() |
106
|
|
|
{ |
107
|
|
|
return $this->field; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @param string $label |
112
|
|
|
*/ |
113
|
|
|
public function setLabel($label) |
114
|
|
|
{ |
115
|
|
|
$this->label = $label; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @return string |
120
|
|
|
*/ |
121
|
|
|
public function getLabel() |
122
|
|
|
{ |
123
|
|
|
return $this->label; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @param boolean $isAvailable |
128
|
|
|
*/ |
129
|
|
|
public function setIsAvailable($isAvailable) |
130
|
|
|
{ |
131
|
|
|
$this->isAvailable = $isAvailable; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @return boolean |
136
|
|
|
*/ |
137
|
|
|
public function getIsAvailable() |
138
|
|
|
{ |
139
|
|
|
return $this->isAvailable; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @param boolean $isUsed |
144
|
|
|
*/ |
145
|
|
|
public function setIsUsed($isUsed) |
146
|
|
|
{ |
147
|
|
|
$this->isUsed = $isUsed; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @return boolean |
152
|
|
|
*/ |
153
|
|
|
public function getIsUsed() |
154
|
|
|
{ |
155
|
|
|
return $this->isUsed; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @return string |
160
|
|
|
*/ |
161
|
|
|
public function getType() |
162
|
|
|
{ |
163
|
|
|
return static::$type; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @return SearchResultSet |
168
|
|
|
*/ |
169
|
|
|
public function getResultSet() |
170
|
|
|
{ |
171
|
|
|
return $this->resultSet; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Get configuration |
176
|
|
|
* |
177
|
|
|
* @return mixed |
178
|
|
|
*/ |
179
|
|
|
public function getConfiguration() |
180
|
|
|
{ |
181
|
|
|
return $this->configuration; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* Get facet partial name used for rendering the facet |
186
|
|
|
* |
187
|
|
|
* @return string |
188
|
|
|
*/ |
189
|
|
|
public function getPartialName() |
190
|
|
|
{ |
191
|
|
|
return 'Default'; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @return string |
196
|
|
|
*/ |
197
|
|
|
public function getGroupName() |
198
|
|
|
{ |
199
|
|
|
return isset($this->configuration['groupName']) ? $this->configuration['groupName'] : 'main'; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* The implementation of this method should return a "flatten" collection of all items. |
204
|
|
|
* |
205
|
|
|
* @return AbstractFacetItemCollection |
206
|
|
|
*/ |
207
|
|
|
abstract public function getAllFacetItems(); |
208
|
|
|
} |
209
|
|
|
|