- Модуль: landing
- Путь к файлу: ~/bitrix/modules/landing/lib/update/block.php
- Класс: BitrixLandingUpdateBlock
- Вызов: Block::execute
public function execute(array &$result)
{
$finished = true;
// check queue
$res = UpdateBlock::getList([
'select' => [
'ID', 'CODE', 'LAST_BLOCK_ID', 'PARAMS'
],
'order' => [
'ID' => 'asc'
],
'limit' => 1
]);
if (!($rowUpdate = $res->fetch()))
{
return false;
}
// gets common quantity
$res = BlockTable::getList([
'select' => [
new BitrixMainEntityExpressionField(
'CNT', 'COUNT(*)'
)
],
'filter' => [
'=CODE' => $rowUpdate['CODE'],
'!=DESIGNED' => 'Y',
]
]);
// skip blocks that not exists
$row = $res->fetch();
if(!$row || (int) $row['CNT'] === 0)
{
UpdateBlock::delete(
$rowUpdate['ID']
);
return $this->execute($result);
}
$result['count'] = $row['CNT'];
// gets finished count
$res = BlockTable::getList([
'select' => [
new BitrixMainEntityExpressionField(
'CNT', 'COUNT(*)'
)
],
'filter' => [
'<=ID' => $rowUpdate['LAST_BLOCK_ID'],
'=CODE' => $rowUpdate['CODE'],
'!=DESIGNED' => 'Y',
]
]
);
if ($row = $res->fetch())
{
$result['steps'] = $row['CNT'];
}
// gets block group for update
$lastId = $this::executeStep([
'>ID' => $rowUpdate['LAST_BLOCK_ID'],
'=CODE' => $rowUpdate['CODE'],
'!=DESIGNED' => 'Y',
],
$count,
$this::STEPPER_COUNT,
$rowUpdate['PARAMS']
);
if ($lastId > 0)
{
$finished = false;
}
// finish or continue
if (!$finished)
{
UpdateBlock::update($rowUpdate['ID'], [
'LAST_BLOCK_ID' => $lastId
]);
return true;
}
else
{
UpdateBlock::delete($rowUpdate['ID']);
return true;//for check next item in UpdateBlock
}
}