/** * {@inheritdoc} */ public function applyConstraint(CalendarResponse &$calendar_response) { parent::applyConstraint($calendar_response); if ($this->start_date === NULL) { $this->start_date = new \DateTime('1970-01-01'); } if ($this->end_date === NULL) { $this->end_date = new \DateTime('2999-12-31'); } if (($calendar_response->getStartDate()->getTimestamp() >= $this->start_date->getTimestamp() && $calendar_response->getStartDate()->getTimestamp() <= $this->end_date->getTimestamp() || $calendar_response->getEndDate()->getTimestamp() >= $this->start_date->getTimestamp() && $calendar_response->getEndDate()->getTimestamp() <= $this->end_date->getTimestamp() || $calendar_response->getStartDate()->getTimestamp() <= $this->start_date->getTimestamp() && $calendar_response->getEndDate()->getTimestamp() >= $this->end_date->getTimestamp()) && ($this->checkin_day === NULL || $this->checkin_day == $calendar_response->getStartDate()->format('N'))) { $units = $this->getUnits(); $included_set = $calendar_response->getIncluded(); foreach ($included_set as $unit_id => $set) { if (isset($units[$unit_id]) || empty($units)) { $start_date = $calendar_response->getStartDate(); $end_date = $calendar_response->getEndDate(); $temp_end_date = clone $end_date; $temp_end_date->add(new \DateInterval('PT1M')); $diff = $temp_end_date->diff($start_date)->days; if (is_numeric($this->min_days) && $diff < $this->min_days) { $calendar_response->removeFromMatched($included_set[$unit_id]['unit'], CalendarResponse::CONSTRAINT, $this); $this->affected_units[$unit_id] = $included_set[$unit_id]['unit']; } elseif (is_numeric($this->max_days) && $diff > $this->max_days) { $calendar_response->removeFromMatched($included_set[$unit_id]['unit'], CalendarResponse::CONSTRAINT, $this); $this->affected_units[$unit_id] = $included_set[$unit_id]['unit']; } } } } }
/** * {@inheritdoc} */ public function applyConstraint(CalendarResponse &$calendar_response) { parent::applyConstraint($calendar_response); if ($this->start_date === NULL) { $this->start_date = new \DateTime('1970-01-01'); } if ($this->end_date === NULL) { $this->end_date = new \DateTime('2999-12-31'); } if (($calendar_response->getStartDate()->getTimestamp() >= $this->start_date->getTimestamp() && $calendar_response->getStartDate()->getTimestamp() <= $this->end_date->getTimestamp() || $calendar_response->getStartDate()->getTimestamp() <= $this->start_date->getTimestamp() && $calendar_response->getEndDate()->getTimestamp() >= $this->end_date->getTimestamp()) && $this->checkin_day != $calendar_response->getStartDate()->format('N')) { $units = $this->getUnits(); $included_set = $calendar_response->getIncluded(); foreach ($included_set as $unit_id => $set) { if (isset($units[$unit_id]) || empty($units)) { $calendar_response->removeFromMatched($included_set[$unit_id]['unit'], CalendarResponse::CONSTRAINT, $this); $this->affected_units[$unit_id] = $included_set[$unit_id]['unit']; } } } }
/** * {@inheritdoc} */ public function applyConstraint(CalendarResponse &$calendar_response) { parent::applyConstraint($calendar_response); if ($this->start_date === NULL) { $this->start_date = new \DateTime('1970-01-01'); } if ($this->end_date === NULL) { $this->end_date = new \DateTime('2999-12-31'); } // If the constraint start date is on or after the requested start date // or the constraint end date is on or before the requested end date, mark // the units as invalid. if ($this->start_date->getTimestamp() >= $calendar_response->getStartDate()->getTimestamp() || $this->end_date->getTimestamp() <= $calendar_response->getEndDate()->getTimestamp()) { $units = $this->getUnits(); $included_set = $calendar_response->getIncluded(); foreach ($included_set as $unit_id => $set) { if (isset($units[$unit_id]) || empty($units)) { $calendar_response->removeFromMatched($included_set[$unit_id]['unit'], CalendarResponse::CONSTRAINT, $this); $this->affected_units[$unit_id] = $included_set[$unit_id]['unit']; } } } }