• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/rest/controllers/scrum/backlog.php
  • Класс: BitrixTasksRestControllersScrumBacklog
  • Вызов: Backlog::deleteAction
public function deleteAction(int $id)
{
	$id = (int) $id;
	if (!$id)
	{
		$this->errorCollection->add([new Error('Backlog id not found')]);

		return null;
	}

	$entityService = new EntityService();

	$backlog = $entityService->getEntityById($id);

	if ($backlog->isEmpty())
	{
		$this->errorCollection->add([new Error('Backlog not found')]);

		return null;
	}

	if ($backlog->getEntityType() !== EntityForm::BACKLOG_TYPE)
	{
		$this->errorCollection->add([new Error('Backlog not found')]);

		return null;
	}

	if (!$this->checkAccess($backlog->getGroupId()))
	{
		$this->errorCollection->add([new Error('Access denied')]);

		return null;
	}

	$itemService = new ItemService();

	$hasBacklogItems = (!empty($itemService->getItemIdsByEntityId($backlog->getId())));

	if ($hasBacklogItems)
	{
		$this->errorCollection->add([new Error('It is forbidden remove a backlog with items')]);

		return null;
	}

	if (!$entityService->removeEntity($id))
	{
		$this->errorCollection->add([new Error('Backlog not deleted')]);
	}

	return [];
}