1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
calendarlogevent.php
См. документацию.
1<?php
2
4
10use Exception;
11
13{
14 private const TYPE_CALENDAR = 'calendar';
15 private const LIMIT = 1000;
16
17 protected static $moduleId = 'socialnetwork';
18
19 private int $lastId = 0;
20 private LogCollection $items;
21
22 public function execute(array &$option): bool
23 {
24 $this
25 ->setLastId($option['lastId'] ?? 0)
26 ->setItems();
27
28 if ($this->items->isEmpty())
29 {
30 return self::FINISH_EXECUTION;
31 }
32
33 $this
34 ->moveItems()
35 ->updateLastId()
36 ->setOptions($option);
37
38 return self::CONTINUE_EXECUTION;
39 }
40
41
42 private function setLastId(int $id): static
43 {
44 $this->lastId = $id;
45 return $this;
46 }
47
48 private function setItems(): static
49 {
50 $this->items = new LogCollection();
51 try
52 {
54 $query
55 ->setSelect(['ID'])
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);
61
62 $this->items = $query->exec()->fetchCollection();
63 }
64 catch (Exception $exception)
65 {
66 $this->writeToLog($exception);
67 return $this;
68 }
69
70 return $this;
71 }
72
73 private function moveItems(): static
74 {
76 $ids = implode(',', $this->items->getIdList());
77 $moduleId = static::TYPE_CALENDAR;
78 $sql = "update {$table} set MODULE_ID = '{$moduleId}' where id in ({$ids})";
79 try
80 {
81 Application::getConnection()->query($sql);
82 }
83 catch (Exception $exception)
84 {
85 $this->writeToLog($exception);
86 }
87
88 return $this;
89 }
90
91 private function updateLastId(): static
92 {
93 $this->lastId = max($this->items->getIdList());
94 return $this;
95 }
96
97 private function setOptions(array &$options): static
98 {
99 $options['lastId'] = $this->lastId;
100 return $this;
101 }
102}
writeToLog(\Exception $exception)
Определения stepper.php:404
static getTableName()
Определения log.php:37
if(!\Bitrix\Main\Loader::includeModule('clouds')) $lastId
Определения sync.php:68
$options
Определения commerceml2.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$query
Определения get_search.php:11
$table
Определения mysql_to_pgsql.php:36
$option
Определения options.php:1711