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

	$userId = UtilUser::getId();

	$epicId = (is_numeric($post['epicId']) ? (int) $post['epicId'] : 0);
	if (!$epicId)
	{
		$this->errorCollection->add([new Error('Epic not found')]);

		return null;
	}

	$epicService = new EpicService($userId);
	$pushService = (Loader::includeModule('pull') ? new PushService() : null);

	$epic = $epicService->getEpic($epicId);
	if (!$epic->getId())
	{
		$this->errorCollection->add([new Error('Epic not found')]);

		return null;
	}

	if (!Group::canReadGroupTasks($userId, $epic->getGroupId()))
	{
		$this->errorCollection->setError(
			new Error(
				Loc::getMessage('TASKS_EC_ERROR_ACCESS_DENIED'),
				self::ERROR_ACCESS_DENIED
			)
		);

		return null;
	}

	$inputEpic = new EpicForm();

	$inputEpic->setId($epicId);
	$inputEpic->setGroupId($post['groupId']);
	$inputEpic->setName($post['name']);
	if ($epic->getName() === '')
	{
		$this->errorCollection->setError(
			new Error(
				Loc::getMessage('TASKS_SCRUM_EPIC_GRID_NAME_ERROR')
			)
		);

		return null;
	}

	$inputEpic->setDescription($post['description']);
	$inputEpic->setModifiedBy($post['modifiedBy'] ?? $userId);
	$inputEpic->setColor($post['color']);

	$files = (is_array($post['files']) ? $post['files'] : []);

	$epicService->updateEpic($epic->getId(), $inputEpic, $pushService);
	if ($epicService->getErrors())
	{
		$this->errorCollection->add([new Error('Epic not updated')]);

		return null;
	}

	$epicService->attachFiles($this->getUserFieldManager(), $epic->getId(), $files);
	if ($epicService->getErrors())
	{
		$this->errorCollection->add([new Error('Epic files not attached')]);

		return null;
	}

	return $inputEpic->toArray();
}