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
|
|
|
* Abstract item that represent a value of a facet. E.g. an option or a node |
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 AbstractFacetItem |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
protected $label = ''; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var int |
34
|
|
|
*/ |
35
|
|
|
protected $documentCount = 0; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var bool |
39
|
|
|
*/ |
40
|
|
|
protected $selected = false; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var array |
44
|
|
|
*/ |
45
|
|
|
protected $metrics = []; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var AbstractFacet |
49
|
|
|
*/ |
50
|
|
|
protected $facet; |
51
|
|
|
|
52
|
|
|
/** |
53
|
77 |
|
* @param AbstractFacet $facet |
54
|
|
|
* @param string $label |
55
|
77 |
|
* @param int $documentCount |
56
|
77 |
|
* @param bool $selected |
57
|
77 |
|
* @param array $metrics |
58
|
77 |
|
*/ |
59
|
77 |
|
public function __construct(AbstractFacet $facet, $label = '', $documentCount = 0, $selected = false, $metrics = []) |
60
|
|
|
{ |
61
|
|
|
$this->facet = $facet; |
62
|
|
|
$this->label = $label; |
63
|
|
|
$this->documentCount = $documentCount; |
64
|
28 |
|
$this->selected = $selected; |
65
|
|
|
$this->metrics = $metrics; |
66
|
28 |
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return int |
70
|
|
|
*/ |
71
|
|
|
public function getDocumentCount() |
72
|
|
|
{ |
73
|
|
|
return $this->documentCount; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return \ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\AbstractFacet |
78
|
|
|
*/ |
79
|
|
|
public function getFacet() |
80
|
28 |
|
{ |
81
|
|
|
return $this->facet; |
82
|
28 |
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return string |
86
|
|
|
*/ |
87
|
|
|
public function getLabel() |
88
|
7 |
|
{ |
89
|
|
|
return $this->label; |
90
|
7 |
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return boolean |
94
|
|
|
*/ |
95
|
|
|
public function getSelected() |
96
|
|
|
{ |
97
|
|
|
return $this->selected; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return array |
102
|
|
|
*/ |
103
|
|
|
public function getMetrics() |
104
|
|
|
{ |
105
|
|
|
return $this->metrics; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return string |
110
|
|
|
*/ |
111
|
|
|
abstract public function getUriValue(); |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return string |
115
|
|
|
*/ |
116
|
|
|
abstract function getCollectionKey(); |
|
|
|
|
117
|
|
|
} |
118
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.