14 private const TYPE_CALENDAR =
'calendar';
15 private const LIMIT = 1000;
19 private int $lastId = 0;
22 public function execute(array &$option): bool
25 ->setLastId($option[
'lastId'] ?? 0)
28 if ($this->items->isEmpty())
36 ->setOptions($option);
42 private function setLastId(
int $id): static
48 private function setItems(): static
56 ->where(
'EVENT_ID', static::TYPE_CALENDAR)
57 ->whereNull(
'MODULE_ID')
58 ->where(
new Condition(
'ID',
'>', $this->lastId))
59 ->setOrder([
'ID' =>
'asc'])
60 ->setLimit(static::LIMIT);
62 $this->items = $query->exec()->fetchCollection();
64 catch (Exception $exception)
73 private function moveItems(): static
76 $ids = implode(
',', $this->items->getIdList());
78 $sql =
"update {$table} set MODULE_ID = '{$moduleId}' where id in ({$ids})";
83 catch (Exception $exception)
91 private function updateLastId(): static
93 $this->lastId = max($this->items->getIdList());
97 private function setOptions(array &$options): static
99 $options[
'lastId'] = $this->lastId;
static getConnection($name="")
writeToLog(\Exception $exception)