* @author Timo Hund */ class DateRange extends AbstractRangeFacetItem { /** * @var DateTime */ protected $startRequested; /** * @var DateTime */ protected $endRequested; /** * @var DateTime */ protected $startInResponse; /** * @var DateTime */ protected $endInResponse; /** * @param DateRangeFacet $facet * @param DateTime|null $startRequested * @param DateTime|null $endRequested * @param DateTime|null $startInResponse * @param DateTime|null $endInResponse * @param string $gap * @param int $documentCount * @param array $rangeCounts * @param bool $selected */ public function __construct(DateRangeFacet $facet, DateTime $startRequested = null, DateTime $endRequested = null, DateTime $startInResponse = null, DateTime $endInResponse = null, $gap = '', $documentCount = 0, $rangeCounts, $selected = false) { $this->startInResponse = $startInResponse; $this->endInResponse = $endInResponse; $this->startRequested = $startRequested; $this->endRequested = $endRequested; $this->rangeCounts = $rangeCounts; $this->gap = $gap; $label = ''; if ($startRequested instanceof DateTime && $endRequested instanceof DateTime) { $label = $this->getRangeString(); } parent::__construct($facet, $label, $documentCount, $selected); } /** * @return string */ protected function getRangeString() { return $this->startRequested->format('Ymd') . '0000-' . $this->endRequested->format('Ymd') . '0000'; } /** * Retrieves the end date that was requested by the user for this facet. * * @return \DateTime */ public function getEndRequested() { return $this->endRequested; } /** * Retrieves the start date that was requested by the used for the facet. * * @return \DateTime */ public function getStartRequested() { return $this->startRequested; } /** * Retrieves the end date that was received from solr for this facet. * * @return \DateTime */ public function getEndInResponse() { return $this->endInResponse; } /** * Retrieves the start date that was received from solr for this facet. * * @return \DateTime */ public function getStartInResponse() { return $this->startInResponse; } }