• Модуль: timeman
  • Путь к файлу: ~/bitrix/modules/timeman/lib/service/schedule/shiftservice.php
  • Класс: BitrixTimemanServiceScheduleShiftService
  • Вызов: ShiftService::add
public function add($scheduleOrId, ShiftForm $shiftForm)
{
	$schedule = $scheduleOrId;
	if (!($schedule instanceof Schedule))
	{
		if (!($schedule = $this->shiftRepository->findScheduleById($scheduleOrId)))
		{
			return (new ShiftServiceResult())->addScheduleNotFoundError();
		}
	}
	$shift = Shift::create(
		$schedule->getId(),
		$schedule->isShifted() ? $shiftForm->name : '',
		$shiftForm->startTime,
		$shiftForm->endTime,
		$shiftForm->breakDuration,
		$shiftForm->workDays
	);
	$saveResult = $this->shiftRepository->save($shift);
	if (!$saveResult->isSuccess())
	{
		return ShiftServiceResult::createByResult($saveResult);
	}

	return (new ShiftServiceResult())->setShift($shift);
}