- Модуль: imconnector
- Путь к файлу: ~/bitrix/modules/imconnector/lib/update/update2000.php
- Класс: BitrixImconnectorUpdateUpdate2000
- Вызов: Update2000::execute
public function execute(array &$option): bool
{
$return = self::FINISH_EXECUTION;
if (Loader::includeModule(self::$moduleId) && Loader::includeModule('rest'))
{
$status = $this->loadCurrentStatus();
if ($status['count'] > 0)
{
$option['progress'] = 1;
$option['steps'] = '';
$option['count'] = $status['count'];
$runtime = [new ReferenceField(
'REST_APP',
AppTable::class,
['=ref.ID' => 'this.REST_APP_ID'],
['join_type' => 'LEFT']
)];
$found = false;
$cursor = CustomConnectorsTable::getList([
'select' => [
'ID',
'ID_CONNECTOR',
'REST_APP_ID',
'REST_APP.ID'
],
'runtime' => $runtime,
'filter' => [
'REST_APP.ID' => null,
'>ID' => $status['lastId'],
],
'offset' => 0,
'limit' => self::PORTION,
'order' => ['ID' => 'ASC'],
]);
while ($row = $cursor->fetch())
{
Helper::unRegisterApp([
'ID' => $row['ID_CONNECTOR'],
'REST_APP_ID' => $row['REST_APP_ID'],
]);
$status['lastId'] = $row['ID'];
$status['number']++;
$found = true;
}
$option['progress'] = floor($status['number'] * 100 / $status['count']);
$option['steps'] = $status['number'];
if ($found)
{
Option::set(self::$moduleId, self::OPTION_NAME, serialize($status));
$return = self::CONTINUE_EXECUTION;
}
else
{
Option::delete(self::$moduleId, ['name' => self::OPTION_NAME]);
}
}
}
return $return;
}