• Модуль: rest
  • Путь к файлу: ~/bitrix/modules/rest/lib/app.php
  • Класс: BitrixRestAppTable
  • Вызов: AppTable::onAfterUpdate
static function onAfterUpdate(MainEntityEvent $event)
{
	$data = $event->getParameters();
	static::clearClientCache($data['primary']['ID']);

	if(!static::$skipRemoteUpdate)
	{
		if(
			isset($data['fields']['STATUS'])
			&& $data['fields']['STATUS'] === static::STATUS_LOCAL
			&& OAuthService::getEngine()->isRegistered()
		)
		{
			$app = static::getByClientId($data['primary']['ID']);

			try
			{
				$updateResult = OAuthService::getEngine()
					->getClient()
					->updateApplication(array(
						"CLIENT_ID" => $app['CLIENT_ID'],
						'TITLE' => $data['fields']['APP_NAME'],
						'REDIRECT_URI' => $data['fields']['URL'],
						'SCOPE' => $data['fields']['SCOPE'],
					));

				if($updateResult['result'])
				{
					return true;
				}
			}
			catch(MainSystemException $e)
			{
				$updateResult = array(
					"error" => $e->getCode(),
					"error_description" => $e->getMessage(),
				);
			}

			throw new OAuthException($updateResult);
		}
	}

	if(isset($data['fields']['STATUS']) && $data['fields']['STATUS'] !== static::STATUS_LOCAL)
	{
		BitrixRestEngineAccess::getActiveEntity(true);
	}

	return true;
}