EventBuilderFromArray::getReminders

  1. Bitrix24 API (v. 23.675.0)
  2. calendar
  3. EventBuilderFromArray
  4. getReminders
  • Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/core/builders/eventbuilderfromarray.php
  • Класс: BitrixCalendarCoreBuildersEventBuilderFromArray
  • Вызов: EventBuilderFromArray::getReminders
protected function getReminders(): RemindCollection
{
	if (isset($this->fields['REMIND']) && is_string($this->fields['REMIND']))
	{
		$this->fields['REMIND'] = unserialize($this->fields['REMIND'], ['allowed_classes' => false]);
	}

	if (!isset($this->fields['REMIND']) || !is_array($this->fields['REMIND']))
	{
		return new RemindCollection();
	}

	$eventStart = $this->getStart();

	$collection = new RemindCollection();
	$collection->setEventStart($eventStart);

	foreach ($this->fields['REMIND'] as $remind)
	{
		if ($remind['type'] === EventToolsDictionary::REMIND_UNIT['date'])
		{
			$collection->add((new EventPropertiesRemind())
				->setSpecificTime(
					new Date(
						Util::getDateObject(
							$remind['value'],
							false,
							$this->fields['TZ_FROM']
						)
					)
				)
				->setEventStart($eventStart)
			);
		}
		elseif ($remind['type'] === EventPropertiesRemind::UNIT_DAY_BEFORE)
		{
			$collection->add((new EventPropertiesRemind())
				->setEventStart($eventStart)
				->setSpecificTime(
					(new Date(
						Util::getDateObject(
							$eventStart->toString(),
							false,
							$this->fields['TZ_FROM'])
					))
					->resetTime()
					->sub("{$remind['before']} days")
					->add("{$remind['time']} minutes")
				)
				->setDaysBefore($remind['before'])
			);
		}
		else
		{
			$collection->add((new EventPropertiesRemind())
				->setTimeBeforeEvent(
					$remind['count'],
					EventToolsDictionary::REMIND_UNIT[$remind['type']]
					?? EventPropertiesRemind::UNIT_MINUTES
				)
				->setEventStart($eventStart)
			);
		}
	}

	return $collection;
}

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