1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the TYPO3 CMS project. |
7
|
|
|
* |
8
|
|
|
* It is free software; you can redistribute it and/or modify it under |
9
|
|
|
* the terms of the GNU General Public License, either version 2 |
10
|
|
|
* of the License, or any later version. |
11
|
|
|
* |
12
|
|
|
* For the full copyright and license information, please read the |
13
|
|
|
* LICENSE.txt file that was distributed with this source code. |
14
|
|
|
* |
15
|
|
|
* The TYPO3 project - inspiring people to share! |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Grouping; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* A group is identified by a groupName and can contain multiple groupItems (that reference the search results). |
22
|
|
|
* |
23
|
|
|
* @author Frans Saris <[email protected]> |
24
|
|
|
* @author Timo Hund <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
class Group |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
protected string $groupName = ''; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var int |
35
|
|
|
*/ |
36
|
|
|
protected int $resultsPerPage = 10; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var GroupItemCollection |
40
|
|
|
*/ |
41
|
|
|
protected GroupItemCollection $groupItems; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Group constructor. |
45
|
|
|
* @param string $groupName |
46
|
|
|
* @param int $resultsPerPage |
47
|
|
|
*/ |
48
|
|
|
public function __construct(string $groupName, int $resultsPerPage = 10) |
49
|
|
|
{ |
50
|
|
|
$this->groupName = $groupName; |
51
|
|
|
$this->groupItems = new GroupItemCollection(); |
52
|
|
|
$this->resultsPerPage = $resultsPerPage; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return string |
57
|
|
|
*/ |
58
|
|
|
public function getGroupName(): string |
59
|
|
|
{ |
60
|
|
|
return $this->groupName; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param string $groupName |
65
|
|
|
*/ |
66
|
|
|
public function setGroupName(string $groupName) |
67
|
|
|
{ |
68
|
|
|
$this->groupName = $groupName; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return GroupItemCollection |
73
|
|
|
*/ |
74
|
|
|
public function getGroupItems(): GroupItemCollection |
75
|
|
|
{ |
76
|
|
|
return $this->groupItems; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param GroupItemCollection $groupItems |
81
|
|
|
*/ |
82
|
|
|
public function setGroupItems(GroupItemCollection $groupItems) |
83
|
|
|
{ |
84
|
|
|
$this->groupItems = $groupItems; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @param GroupItem $groupItem |
89
|
|
|
*/ |
90
|
|
|
public function addGroupItem(GroupItem $groupItem) |
91
|
|
|
{ |
92
|
|
|
$this->groupItems[] = $groupItem; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return int |
97
|
|
|
*/ |
98
|
|
|
public function getResultsPerPage(): int |
99
|
|
|
{ |
100
|
|
|
return $this->resultsPerPage; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param int $resultsPerPage |
105
|
|
|
*/ |
106
|
|
|
public function setResultsPerPage(int $resultsPerPage) |
107
|
|
|
{ |
108
|
|
|
$this->resultsPerPage = $resultsPerPage; |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|