1
|
|
|
<?php |
2
|
|
|
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Grouping; |
3
|
|
|
|
4
|
|
|
/*************************************************************** |
5
|
|
|
* Copyright notice |
6
|
|
|
* |
7
|
|
|
* (c) 2017 Timo Hund <[email protected]> |
8
|
|
|
* All rights reserved |
9
|
|
|
* |
10
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
11
|
|
|
* free software; you can redistribute it and/or modify |
12
|
|
|
* it under the terms of the GNU General Public License as published by |
13
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
14
|
|
|
* (at your option) any later version. |
15
|
|
|
* |
16
|
|
|
* The GNU General Public License can be found at |
17
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
18
|
|
|
* |
19
|
|
|
* This script is distributed in the hope that it will be useful, |
20
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
21
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22
|
|
|
* GNU General Public License for more details. |
23
|
|
|
* |
24
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
25
|
|
|
***************************************************************/ |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* A group is identified by a groupName and can contain multiple groupItems (that reference the search results). |
29
|
|
|
* |
30
|
|
|
* @author Frans Saris <[email protected]> |
31
|
|
|
* @author Timo Hund <[email protected]> |
32
|
|
|
* @package ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Grouping |
33
|
|
|
*/ |
34
|
|
|
class Group |
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
protected $groupName = ''; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var int |
43
|
|
|
*/ |
44
|
|
|
protected $resultsPerPage = 10; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var GroupItemCollection |
48
|
|
|
*/ |
49
|
|
|
protected $groupItems = null; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var array |
53
|
|
|
*/ |
54
|
|
|
protected $groupConfiguration = []; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Group constructor. |
58
|
|
|
* @param string $groupName |
59
|
|
|
* @param int $resultsPerPage |
60
|
|
|
*/ |
61
|
|
|
public function __construct(string $groupName, int $resultsPerPage = 10) |
62
|
|
|
{ |
63
|
|
|
$this->groupName = $groupName; |
64
|
|
|
$this->groupItems = new GroupItemCollection(); |
65
|
|
|
$this->resultsPerPage = $resultsPerPage; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return string |
70
|
|
|
*/ |
71
|
|
|
public function getGroupName(): string |
72
|
|
|
{ |
73
|
|
|
return $this->groupName; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param string $groupName |
78
|
|
|
*/ |
79
|
|
|
public function setGroupName(string $groupName) |
80
|
|
|
{ |
81
|
|
|
$this->groupName = $groupName; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return GroupItemCollection |
86
|
|
|
*/ |
87
|
|
|
public function getGroupItems(): GroupItemCollection |
88
|
|
|
{ |
89
|
|
|
return $this->groupItems; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param GroupItemCollection $groupItems |
94
|
|
|
*/ |
95
|
|
|
public function setGroupItems(GroupItemCollection $groupItems) |
96
|
|
|
{ |
97
|
|
|
$this->groupItems = $groupItems; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param GroupItem $groupItem |
102
|
|
|
*/ |
103
|
|
|
public function addGroupItem(GroupItem $groupItem) |
104
|
|
|
{ |
105
|
|
|
$this->groupItems[] = $groupItem; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return int |
110
|
|
|
*/ |
111
|
|
|
public function getResultsPerPage(): int |
112
|
|
|
{ |
113
|
|
|
return $this->resultsPerPage; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @param int $resultsPerPage |
118
|
|
|
*/ |
119
|
|
|
public function setResultsPerPage(int $resultsPerPage) |
120
|
|
|
{ |
121
|
|
|
$this->resultsPerPage = $resultsPerPage; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|