- Модуль: rest
- Путь к файлу: ~/bitrix/modules/rest/lib/preset/provider.php
- Класс: BitrixRestPresetProvider
- Вызов: Provider::getIntegration
static function getIntegration($id)
{
$id = intVal($id);
$return = [];
$runtime = [
new ReferenceField(
'APPLICATION_DATA',
AppTable::class,
[
'=ref.ID' => 'this.APP_ID'
],
[
'join_type' => 'LEFT'
]
),
new ReferenceField(
'PASSWORD_DATA',
PasswordTable::class,
[
'=ref.ID' => 'this.PASSWORD_ID'
],
[
'join_type' => 'LEFT'
]
),
];
$select = [
'*',
'APPLICATION_DATA_' => 'APPLICATION_DATA',
'PASSWORD_DATA_' => 'PASSWORD_DATA'
];
if (Loader::includeModule('im'))
{
$runtime[] = new ReferenceField(
'BOT_DATA',
BotTable::class,
[
'=ref.BOT_ID' => 'this.BOT_ID'
],
[
'join_type' => 'LEFT'
]
);
$select['BOT_DATA_'] = 'BOT_DATA';
$runtime[] = new ReferenceField(
'BOT_ACCOUNT',
UserTable::class,
[
'=ref.ID' => 'this.BOT_ID'
],
[
'join_type' => 'LEFT'
]
);
$select['BOT_ACCOUNT_NAME'] = 'BOT_ACCOUNT.NAME';
}
$res = IntegrationTable::getList(
[
'filter' => [
'=ID' => $id
],
'limit' => 1,
'select' => $select,
'runtime' => $runtime
]
);
if ($item = $res->fetch())
{
if ($item['PASSWORD_DATA_ID'] > 0)
{
$item['PASSWORD_DATA_URL'] = CRestUtil::getWebhookEndpoint(
$item['PASSWORD_DATA_PASSWORD'],
$item['PASSWORD_DATA_USER_ID']
);
}
if (!empty($item['BOT_DATA_APP_ID']) && mb_strpos($item['BOT_DATA_APP_ID'], 'custom') === 0)
{
//clear 'custom' prefix only for webhook bot
$item['BOT_DATA_APP_ID'] = mb_substr($item['BOT_DATA_APP_ID'], 6);
}
if ($item['APP_ID'] > 0 && $item['APPLICATION_ONLY_API'] == 'N')
{
$resLang = AppLangTable::getList(
[
'filter' => [
'=APP_ID' => $item['APP_ID']
]
]
);
while ($lang = $resLang->fetch())
{
$item['APPLICATION_LANG_DATA'][$lang['LANGUAGE_ID']] = $lang['MENU_NAME'];
}
}
if ($item['APP_ID'] > 0 && !empty($item['WIDGET_LIST']))
{
$resLang = PlacementTable::getList(
[
'filter' => [
'=APP_ID' => $item['APP_ID'],
],
'select' => [
'ID',
'LANG_ALL',
],
]
);
foreach ($resLang->fetchCollection() as $placement)
{
if (!is_null($placement->getLangAll()))
{
foreach ($placement->getLangAll() as $lang)
{
$item['WIDGET_LANG_LIST'][$lang->getLanguageId()] = [
'TITLE' => $lang->getTitle(),
'DESCRIPTION' => $lang->getDescription(),
'GROUP_NAME' => $lang->getGroupName(),
];
}
}
}
}
$return = $item;
}
return $return;
}