• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/rest/controllers/task/result.php
  • Класс: BitrixTasksRestControllersTaskResult
  • Вызов: Result::getLastAction
public function getLastAction(int $taskId): ?array
{
	if ($taskId <= 0)
	{
		$this->errorCollection->setError(new Error('Task not found.'));
		return null;
	}

	if ($this->getUserId() <= 0)
	{
		$this->errorCollection->setError(new Error('Access denied.'));
		return null;
	}

	if (!Loader::includeModule('tasks'))
	{
		$this->errorCollection->setError(new Error('Module not loaded.'));
		return null;
	}

	if (!TaskAccessController::can($this->getUserId(), ActionDictionary::ACTION_TASK_READ, $taskId))
	{
		$this->errorCollection->setError(new Error('Access denied.'));
		return null;
	}

	try
	{
		$task = new TaskObject(['ID' => $taskId]);
		$result = $task->getLastResult();
		if (is_null($result))
		{
			return ['result' => 0];
		}
		$resultId = $result->getId();
	}
	catch (Exception $exception)
	{
		$this->errorCollection->setError(new Error($exception->getMessage()));
		return null;
	}

	return ['result' => $resultId];
}