booked/lib/Application/Reservation/Validation/ReservationStartTimeRule.php
/**
     * @param ReservationSeries $reservationSeries
     * @param $retryParameters
     * @return ReservationRuleResult
     * @throws Exception
     */
@param ReservationSeries $reservationSeries
@param $retryParameters
@return ReservationRuleResult
@throws Exception
@param ReservationSeries $reservationSeries @param $retryParameters @return ReservationRuleResult @throws Exception
public function Validate($reservationSeries, $retryParameters)
	{
        $constraint = Configuration::Instance()->GetSectionKey(ConfigSection::RESERVATION, ConfigKeys::RESERVATION_START_TIME_CONSTRAINT);
        if (empty($constraint))
        {
            $constraint = ReservationStartTimeConstraint::_DEFAULT;
        }
        if ($constraint == ReservationStartTimeConstraint::NONE)
        {
            return new ReservationRuleResult();
        }
        $currentInstance = $reservationSeries->CurrentInstance();
        $dateThatShouldBeLessThanNow = $currentInstance->StartDate();
        if ($constraint == ReservationStartTimeConstraint::CURRENT)
        {
            $timezone = $dateThatShouldBeLessThanNow->Timezone();
			$currentPeriod = $this->scheduleRepository
					->GetLayout($reservationSeries->ScheduleId(), new ScheduleLayoutFactory($timezone))
					->GetPeriod($currentInstance->EndDate());
            $dateThatShouldBeLessThanNow = $currentPeriod->BeginDate();
        }
		Log::Debug("Start Time Rule: Comparing %s to %s", $dateThatShouldBeLessThanNow, Date::Now());
		$startIsInFuture = $dateThatShouldBeLessThanNow->Compare(Date::Now()) >= 0;
		return new ReservationRuleResult($startIsInFuture, Resources::GetInstance()->GetString('StartIsInPast'));
	}
public function Validate ( $ reservationSeries , $ retryParameters ) { $ constraint = Configuration :: Instance ( ) -> GetSectionKey ( ConfigSection :: RESERVATION , ConfigKeys :: RESERVATION_START_TIME_CONSTRAINT ) ; if ( empty ( $ constraint ) ) { $ constraint = ReservationStartTimeConstraint :: _DEFAULT ; } if ( $ constraint == ReservationStartTimeConstraint :: NONE ) { return new ReservationRuleResult ( ) ; } $ currentInstance = $ reservationSeries -> CurrentInstance ( ) ; $ dateThatShouldBeLessThanNow = $ currentInstance -> StartDate ( ) ; if ( $ constraint == ReservationStartTimeConstraint :: CURRENT ) { $ timezone = $ dateThatShouldBeLessThanNow -> Timezone ( ) ; $ currentPeriod = $ this -> scheduleRepository -> GetLayout ( $ reservationSeries -> ScheduleId ( ) , new ScheduleLayoutFactory ( $ timezone ) ) -> GetPeriod ( $ currentInstance -> EndDate ( ) ) ; $ dateThatShouldBeLessThanNow = $ currentPeriod -> BeginDate ( ) ; } Log :: Debug ( " Start Time Rule: Comparing %s to %s " , $ dateThatShouldBeLessThanNow , Date :: Now ( ) ) ; $ startIsInFuture = $ dateThatShouldBeLessThanNow -> Compare ( Date :: Now ( ) ) >= 0 ; return new ReservationRuleResult ( $ startIsInFuture , Resources :: GetInstance ( ) -> GetString ( 'StartIsInPast' ) ) ; }
@param ReservationSeries $reservationSeries
 @param $retryParameters
 @return ReservationRuleResult
 @throws Exception
@param ReservationSeries $reservationSeries @param $retryParameters @return ReservationRuleResult @throws Exception
/** @var $currentPeriod SchedulePeriod */