|
1
|
|
|
<?php |
|
2
|
|
|
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\RangeBased\DateRange; |
|
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
|
|
|
|
|
17
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\RangeBased\AbstractRangeFacetItem; |
|
18
|
|
|
use DateTime; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Value object that represent an option of a options facet. |
|
22
|
|
|
* |
|
23
|
|
|
* @author Frans Saris <[email protected]> |
|
24
|
|
|
* @author Timo Hund <[email protected]> |
|
25
|
|
|
* @package ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\OptionsFacet |
|
26
|
|
|
*/ |
|
27
|
|
|
class DateRange extends AbstractRangeFacetItem |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* @var DateTime |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $startRequested; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var DateTime |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $endRequested; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var DateTime |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $startInResponse; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var DateTime |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $endInResponse; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param DateRangeFacet $facet |
|
51
|
|
|
* @param DateTime|null $startRequested |
|
52
|
|
|
* @param DateTime|null $endRequested |
|
53
|
|
|
* @param DateTime|null $startInResponse |
|
54
|
|
|
* @param DateTime|null $endInResponse |
|
55
|
|
|
* @param string $gap |
|
56
|
|
|
* @param int $documentCount |
|
57
|
|
|
* @param array $rangeCounts |
|
58
|
|
|
* @param bool $selected |
|
59
|
|
|
*/ |
|
60
|
2 |
|
public function __construct(DateRangeFacet $facet, DateTime $startRequested = null, DateTime $endRequested = null, DateTime $startInResponse = null, DateTime $endInResponse = null, $gap = '', $documentCount = 0, $rangeCounts, $selected = false) |
|
61
|
|
|
{ |
|
62
|
2 |
|
$this->startInResponse = $startInResponse; |
|
63
|
2 |
|
$this->endInResponse = $endInResponse; |
|
64
|
2 |
|
$this->startRequested = $startRequested; |
|
65
|
2 |
|
$this->endRequested = $endRequested; |
|
66
|
2 |
|
$this->rangeCounts = $rangeCounts; |
|
67
|
2 |
|
$this->gap = $gap; |
|
68
|
|
|
|
|
69
|
2 |
|
$label = ''; |
|
70
|
2 |
|
if ($startRequested instanceof DateTime && $endRequested instanceof DateTime) { |
|
71
|
1 |
|
$label = $this->getRangeString(); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
2 |
|
parent::__construct($facet, $label, $documentCount, $selected); |
|
76
|
2 |
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @return string |
|
80
|
|
|
*/ |
|
81
|
1 |
|
protected function getRangeString() |
|
82
|
|
|
{ |
|
83
|
1 |
|
return $this->startRequested->format('Ymd') . '0000-' . $this->endRequested->format('Ymd') . '0000'; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Retrieves the end date that was requested by the user for this facet. |
|
88
|
|
|
* |
|
89
|
|
|
* @return \DateTime |
|
90
|
|
|
*/ |
|
91
|
1 |
|
public function getEndRequested() |
|
92
|
|
|
{ |
|
93
|
1 |
|
return $this->endRequested; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Retrieves the start date that was requested by the used for the facet. |
|
98
|
|
|
* |
|
99
|
|
|
* @return \DateTime |
|
100
|
|
|
*/ |
|
101
|
1 |
|
public function getStartRequested() |
|
102
|
|
|
{ |
|
103
|
1 |
|
return $this->startRequested; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Retrieves the end date that was received from solr for this facet. |
|
108
|
|
|
* |
|
109
|
|
|
* @return \DateTime |
|
110
|
|
|
*/ |
|
111
|
2 |
|
public function getEndInResponse() |
|
112
|
|
|
{ |
|
113
|
2 |
|
return $this->endInResponse; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Retrieves the start date that was received from solr for this facet. |
|
118
|
|
|
* |
|
119
|
|
|
* @return \DateTime |
|
120
|
|
|
*/ |
|
121
|
2 |
|
public function getStartInResponse() |
|
122
|
|
|
{ |
|
123
|
2 |
|
return $this->startInResponse; |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|