• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/scrum/controllers/sprint.php
  • Класс: BitrixTasksScrumControllersSprint
  • Вызов: Sprint::startSprintAction
public function startSprintAction(): ?string
{
	$post = $this->request->getPostList()->toArray();

	$userId = User::getId();

	$groupId = (is_numeric($post['groupId']) ? (int) $post['groupId'] : 0);

	$sprintService = new SprintService();

	if (!$sprintService->canStartSprint($userId, $groupId))
	{
		$this->errorCollection->setError(
			new Error(
				Loc::getMessage('TSSC_ERROR_ACCESS_DENIED'),
				self::ERROR_ACCESS_DENIED
			)
		);

		return null;
	}

	$sprintId = (is_numeric($post['sprintId']) ? (int) $post['sprintId'] : 0);
	$name = (is_string($post['name']) ? $post['name'] : '');
	$dateStart = (is_numeric($post['dateStart']) ? (int) $post['dateStart'] : 0);
	$dateEnd = (is_numeric($post['dateEnd']) ? (int) $post['dateEnd'] : 0);

	$sprint = $sprintService->getSprintById($sprintId);
	if ($sprint->isEmpty())
	{
		$this->errorCollection->setError(
			new Error(
				Loc::getMessage('TASKS_SCRUM_SPRINT_START_ERROR'),
				self::ERROR_COULD_NOT_START_SPRINT
			)
		);

		return null;
	}

	$sprint->setName($name);
	if ($dateStart)
	{
		$sprint->setDateStart(DateTime::createFromTimestamp($dateStart));
	}
	if ($dateEnd)
	{
		$sprint->setDateEnd(DateTime::createFromTimestamp($dateEnd));
	}

	$sprintInfo = new EntityInfo();
	if (!empty($post[$sprintInfo->getSprintGoalKey()]))
	{
		$sprintInfo->setSprintGoal($post[$sprintInfo->getSprintGoalKey()]);
	}
	$sprintInfo->setSprintStagesRecoveryStatusToWaiting();

	$sprint->setInfo($sprintInfo);

	$sprintService->changeSprint($sprint);

	$kanbanService = new KanbanService();
	$taskService = new TaskService($userId);
	$itemService = new ItemService();
	$backlogService = new BacklogService();
	$robotService = (Loader::includeModule('bizproc') ? new RobotService() : null);
	$pushService = (Loader::includeModule('pull') ? new PushService() : null);

	$sprintService->startSprint(
		$sprint,
		$taskService,
		$kanbanService,
		$itemService,
		$backlogService,
		$robotService,
		$pushService
	);

	if ($sprintService->getErrors())
	{
		$this->errorCollection->add($sprintService->getErrors());

		return null;
	}

	return '';
}