|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result; |
|
4
|
|
|
|
|
5
|
|
|
/*************************************************************** |
|
6
|
|
|
* Copyright notice |
|
7
|
|
|
* |
|
8
|
|
|
* (c) 2015-2016 Timo Schmidt <[email protected]> |
|
9
|
|
|
* All rights reserved |
|
10
|
|
|
* |
|
11
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
|
12
|
|
|
* free software; you can redistribute it and/or modify |
|
13
|
|
|
* it under the terms of the GNU General Public License as published by |
|
14
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
15
|
|
|
* (at your option) any later version. |
|
16
|
|
|
* |
|
17
|
|
|
* The GNU General Public License can be found at |
|
18
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
|
19
|
|
|
* |
|
20
|
|
|
* This script is distributed in the hope that it will be useful, |
|
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23
|
|
|
* GNU General Public License for more details. |
|
24
|
|
|
* |
|
25
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
|
26
|
|
|
***************************************************************/ |
|
27
|
|
|
|
|
28
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Grouping\GroupItem; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Proxy class for \Apache_Solr_Document to customize \Apache_Solr_Document without |
|
32
|
|
|
* changing the library code. |
|
33
|
|
|
* |
|
34
|
|
|
* Implements |
|
35
|
|
|
* |
|
36
|
|
|
* @author Timo Schmidt <[email protected]> |
|
37
|
|
|
*/ |
|
38
|
|
|
class SearchResult extends \Apache_Solr_Document |
|
39
|
|
|
{ |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var bool |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $throwExceptions = false; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var SearchResult[] |
|
48
|
|
|
*/ |
|
49
|
|
|
protected $variants = []; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Indicates if an instance of this document is a variant (a sub document of another). |
|
53
|
|
|
* |
|
54
|
|
|
* @var bool |
|
55
|
|
|
*/ |
|
56
|
|
|
protected $isVariant = false; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* References the parent document of the document is a variant. |
|
60
|
|
|
* |
|
61
|
|
|
* @var null |
|
62
|
|
|
*/ |
|
63
|
|
|
protected $variantParent = null; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @var GroupItem |
|
67
|
|
|
*/ |
|
68
|
|
|
protected $groupItem = null; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @param \Apache_Solr_Document $document |
|
72
|
|
|
* @param bool $throwExceptions |
|
73
|
|
|
*/ |
|
74
|
42 |
|
public function __construct(\Apache_Solr_Document $document, $throwExceptions = false) |
|
|
|
|
|
|
75
|
|
|
{ |
|
76
|
42 |
|
$this->throwExceptions = false; |
|
77
|
42 |
|
$this->_documentBoost = $document->_documentBoost; |
|
78
|
42 |
|
$this->_fields = $document->_fields; |
|
79
|
42 |
|
$this->_fieldBoosts = $document->_fieldBoosts; |
|
80
|
42 |
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @param string $name |
|
84
|
|
|
* @param array $arguments |
|
85
|
|
|
* @throws \Exception |
|
86
|
|
|
* @throws \RuntimeException |
|
87
|
|
|
* @return string |
|
88
|
|
|
*/ |
|
89
|
|
|
public function __call($name, $arguments) |
|
90
|
|
|
{ |
|
91
|
|
|
try { |
|
92
|
|
|
return parent::__call($name, $arguments); |
|
93
|
|
|
} catch (\RuntimeException $e) { |
|
94
|
|
|
if ($this->throwExceptions) { |
|
95
|
|
|
throw $e; |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @return GroupItem |
|
102
|
|
|
*/ |
|
103
|
|
|
public function getGroupItem(): GroupItem |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->groupItem; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @return bool |
|
110
|
|
|
*/ |
|
111
|
|
|
public function getHasGroupItem() |
|
112
|
|
|
{ |
|
113
|
|
|
return $this->groupItem !== null; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @param GroupItem $group |
|
118
|
|
|
*/ |
|
119
|
2 |
|
public function setGroupItem(GroupItem $group) |
|
120
|
|
|
{ |
|
121
|
2 |
|
$this->groupItem = $group; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* @return SearchResult[] |
|
126
|
|
|
*/ |
|
127
|
2 |
|
public function getVariants() |
|
128
|
|
|
{ |
|
129
|
2 |
|
return $this->variants; |
|
130
|
2 |
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* @param SearchResult $expandedResult |
|
134
|
|
|
*/ |
|
135
|
1 |
|
public function addVariant(SearchResult $expandedResult) |
|
136
|
|
|
{ |
|
137
|
1 |
|
$this->variants[] = $expandedResult; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* @return bool |
|
142
|
|
|
*/ |
|
143
|
2 |
|
public function getIsVariant() |
|
144
|
|
|
{ |
|
145
|
2 |
|
return $this->isVariant; |
|
146
|
2 |
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* @param bool $isVariant |
|
150
|
|
|
*/ |
|
151
|
|
|
public function setIsVariant($isVariant) |
|
152
|
|
|
{ |
|
153
|
|
|
$this->isVariant = $isVariant; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* @return null |
|
158
|
|
|
*/ |
|
159
|
2 |
|
public function getVariantParent() |
|
160
|
|
|
{ |
|
161
|
2 |
|
return $this->variantParent; |
|
162
|
2 |
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* @param null $variantParent |
|
|
|
|
|
|
166
|
|
|
*/ |
|
167
|
28 |
|
public function setVariantParent($variantParent) |
|
168
|
|
|
{ |
|
169
|
28 |
|
$this->variantParent = $variantParent; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* @return string |
|
174
|
|
|
*/ |
|
175
|
27 |
|
public function getContent() |
|
176
|
|
|
{ |
|
177
|
27 |
|
return $this->_fields['content']; |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* @return boolean |
|
182
|
|
|
*/ |
|
183
|
28 |
|
public function getIsElevated() |
|
184
|
|
|
{ |
|
185
|
28 |
|
return $this->_fields['isElevated']; |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
/** |
|
189
|
|
|
* @return string |
|
190
|
|
|
*/ |
|
191
|
27 |
|
public function getType() |
|
192
|
|
|
{ |
|
193
|
27 |
|
return $this->_fields['type']; |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
/** |
|
197
|
|
|
* @return integer |
|
198
|
|
|
*/ |
|
199
|
27 |
|
public function getId() |
|
200
|
|
|
{ |
|
201
|
27 |
|
return $this->_fields['id']; |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
/** |
|
205
|
|
|
* @return float |
|
206
|
|
|
*/ |
|
207
|
28 |
|
public function getScore() |
|
208
|
|
|
{ |
|
209
|
28 |
|
return $this->_fields['score']; |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* @return string |
|
214
|
|
|
*/ |
|
215
|
30 |
|
public function getUrl() |
|
216
|
|
|
{ |
|
217
|
30 |
|
return $this->_fields['url']; |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
/** |
|
221
|
|
|
* @return string |
|
222
|
|
|
*/ |
|
223
|
|
|
public function getTitle() |
|
224
|
|
|
{ |
|
225
|
|
|
return $this->_fields['title']; |
|
226
|
|
|
} |
|
227
|
|
|
} |
|
228
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.