|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Grouping; |
|
4
|
|
|
|
|
5
|
|
|
/*************************************************************** |
|
6
|
|
|
* Copyright notice |
|
7
|
|
|
* |
|
8
|
|
|
* (c) 2017 Timo Hund <[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 2 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\System\Data\AbstractCollection; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* The Group contains the Group objects. |
|
32
|
|
|
* |
|
33
|
|
|
* @package ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Grouping |
|
34
|
|
|
*/ |
|
35
|
|
|
class GroupCollection extends AbstractCollection { |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param string $name |
|
39
|
|
|
* @return Group |
|
40
|
|
|
*/ |
|
41
|
|
|
public function getByName($name): Group |
|
42
|
|
|
{ |
|
43
|
|
|
foreach($this->data as $group) { |
|
44
|
|
|
/** @var $group Group */ |
|
45
|
|
|
if($group->getGroupName() === $name) { |
|
46
|
|
|
return $group; |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
return null; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @param string $name |
|
55
|
|
|
* @return boolean |
|
56
|
|
|
*/ |
|
57
|
|
|
public function getHasWithName($name): bool |
|
58
|
|
|
{ |
|
59
|
|
|
foreach($this->data as $group) { |
|
60
|
|
|
/** @var $group Group */ |
|
61
|
|
|
if($group->getGroupName() === $name) { |
|
62
|
|
|
return true; |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
return false; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @return array |
|
71
|
|
|
*/ |
|
72
|
|
|
public function getGroupNames(): array |
|
73
|
|
|
{ |
|
74
|
|
|
$names = []; |
|
75
|
|
|
foreach($this->data as $group) { |
|
76
|
|
|
/** @var $group Group */ |
|
77
|
|
|
$names[] = $group->getGroupName(); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
return $names; |
|
81
|
|
|
} |
|
82
|
|
|
} |