• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/dispatcher.php
  • Класс: BitrixTasksDOES
  • Вызов: DOES::restGateway
static function restGateway($queryArguments)
{
	if (static::$currentRestMehtod === null)
	{
		throw new RestException('Method not found!', 'ERROR_METHOD_NOT_FOUND');
	}

	// run Dispatcher
	$dispatcher = new self();
	$plan = new DispatcherToDoPlan();
	$plan->import([
		[
			'OPERATION' => static::$currentRestMehtod,
			'ARGUMENTS' => $queryArguments,
		],
	]);
	$result = $dispatcher->run($plan);

	// work with result
	if ($result->isSuccess())
	{
		$return = array_values($plan->exportResult());
		$errors = $result->getErrors();

		if ($errors && !$errors->isEmpty())
		{
			$error = $errors->first();
			throw new RestException($error->getMessage(), $error->getCode());
		}

		if (isset($return[0]['RESULT']))
		{
			return $return[0]['RESULT'];
		}

		throw new RestException('Unknown error', 'UNKNOWN_ERROR');
	}

	$errors = $result->getErrors();
	$error = $errors->first();

	throw new RestException($error->getMessage(), 'DISPATCHER_ERROR');
}