Recurrence::prepareLimits

  1. Bitrix24 API (v. 23.675.0)
  2. calendar
  3. Recurrence
  4. prepareLimits
  • Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/core/event/tools/recurrence.php
  • Класс: BitrixCalendarCoreEventToolsRecurrence
  • Вызов: Recurrence::prepareLimits
private function prepareLimits(Event $event, array $params): array
{
	$getCount = static function (Event $event, array $params)
	{
		return $params['limitCount']
			?? $event->getRecurringRule()
				? $event->getRecurringRule()->getCount()
				: null
			;
	};

	$getFrom = function (Event $event, array $params)
	{
		if (!empty($params['limitDateFrom']))
		{
			return max(
				$this->convertBitrixDateToPhpDate($params['limitDateFrom']),
				$this->convertBitrixDateToPhpDate($event->getStart())
			);
		}
		else
		{
			return $this->convertBitrixDateToPhpDate($event->getStart());
		}
	};

	$getTo = function (Event $event, array $params)
	{
		$until = (!is_null($event->getRecurringRule()) && $event->getRecurringRule()->hasUntil())
			? $this->convertBitrixDateToPhpDate($event->getRecurringRule()->getUntil())
			: null;
		if (empty($params['limitDateTo']))
		{
			return $until;
		}
		elseif ($until)
		{
			return min(
				$this->convertBitrixDateToPhpDate($params['limitDateTo']),
				$until
			);
		}
		else
		{
			return $params['limitDateTo'];
		}
	};

	return [
		'count' => $getCount($event, $params),
		'from' => $getFrom($event, $params),
		'to' => $getTo($event, $params),
	];
}

Добавить комментарий