• Модуль: rest
  • Путь к файлу: ~/bitrix/modules/rest/lib/app.php
  • Класс: BitrixRestAppTable
  • Вызов: AppTable::getByClientId
static function getByClientId($clientId)
{
	if(!array_key_exists($clientId, static::$applicationCache))
	{
		if(strval(intval($clientId)) == $clientId)
		{
			$filter = array('=ID' => $clientId);
		}
		else
		{
			$filter = array(
				array(
					'LOGIC' => 'OR',
					'=CODE' => $clientId,
					'=CLIENT_ID' => $clientId,
				),
			);
		}

		$dbRes = static::getList(
			[
				'filter' => $filter,
				'select' => [
					'*',
					'MENU_NAME' => 'LANG.MENU_NAME',
					'MENU_NAME_DEFAULT' => 'LANG_DEFAULT.MENU_NAME',
					'MENU_NAME_LICENSE' => 'LANG_LICENSE.MENU_NAME',
				],
				'limit' => 1,
			]
		);

		foreach ($dbRes->fetchCollection() as $app)
		{
			$appInfo = [
				'ID' => $app->getId(),
				'MENU_NAME' => !is_null($app->getLang()) ? $app->getLang()->getMenuName() : '',
				'MENU_NAME_DEFAULT' => !is_null($app->getLangDefault()) ? $app->getLangDefault()->getMenuName() : '',
				'MENU_NAME_LICENSE' => !is_null($app->getLangLicense()) ? $app->getLangLicense()->getMenuName() : '',
			];
			foreach ($app->sysGetEntity()->getScalarFields() as $field)
			{
				$fieldName = $field->getName();
				if ($field instanceof BooleanField)
				{
					$appInfo[$fieldName] = $app->get($fieldName) ? 'Y' : 'N';
				}
				else
				{
					$appInfo[$fieldName] = $app->get($fieldName);
				}
			}
			$app->fillLangAll();
			if (!is_null($app->getLangAll()))
			{
				foreach ($app->getLangAll() as $lang)
				{
					$appInfo['LANG_ALL'][$lang->getLanguageId()] = [
						'MENU_NAME' => $lang->getMenuName(),
					];
				}
			}
			if ($appInfo['MENU_NAME'] === '')
			{
				$appInfo = Lang::mergeFromLangAll($appInfo);
			}
		}

		if (isset($appInfo) && is_array($appInfo))
		{
			static::$applicationCache[$appInfo['ID']] = $appInfo;
			static::$applicationCache[$appInfo['CLIENT_ID']] = $appInfo;
			static::$applicationCache[$appInfo['CODE']] = $appInfo;
		}
	}

	return static::$applicationCache[$clientId];
}