• Модуль: rest
  • Путь к файлу: ~/bitrix/modules/rest/lib/configuration/action/base.php
  • Класс: BitrixRestConfigurationActionBase
  • Вызов: Base::register
public function register(array $data, array $additionalOptions = [], int $userId = 0, string $appCode = '', bool $byAgent = true): array
{
	$result = static::checkRegister($data);
	if (!empty($result['error']))
	{
		return $result;
	}

	$data = $this->prepareData($data);
	$file = CRestUtil::saveFile(base64_encode(Json::encode($data)));
	$file['MODULE_ID'] = static::MODULE_ID;
	$processId = CFile::SaveFile(
		$file,
		'configuration/' . static::ACTION
	);

	if ($processId > 0)
	{
		$this->setProcessId($processId);
		$isSave = $this->getSetting()->set(
			Structure::CODE_CUSTOM_FILE . static::ACTION,
			[
				'ID' => $processId,
			]
		);
		if ($isSave)
		{
			$this->getSetting()->set(
				Setting::SETTING_ACTION_ADDITIONAL_OPTION,
				$additionalOptions
			);

			$this->getSetting()->set(
				Setting::SETTING_USER_ID,
				$userId
			);

			if (!empty($appCode))
			{
				$app = AppTable::getByClientId($appCode);
				if (is_array($app))
				{
					$this->getSetting()->set(
						Setting::SETTING_APP_INFO,
						$app
					);
				}
			}

			$this->setStatus(self::STATUS_START);
			$result['processId'] = $processId;
			if ($byAgent)
			{
				CAgent::AddAgent(
					static::class . '::runAgent(' . $processId . ');',
					static::MODULE_ID,
					'N',
					60,
					'',
					'Y',
					ConvertTimeStamp(time() + CTimeZone::GetOffset() + 60, 'FULL')
				);
			}
		}
		else
		{
			$this->setStatus(self::STATUS_ERROR);
		}
	}

	if (!$result['processId'])
	{
		$result['error'] = static::ERROR_PROCESS_DID_NOT_CREATE;
	}

	return $result;
}