1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
updateeventtypeagent.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
5namespace Bitrix\Calendar\Integration\SocialNetwork\Collab\Converter;
6
7use Bitrix\Calendar\Core\Event\Tools\Dictionary;
8use Bitrix\Calendar\Internals\EventTable;
9
11{
12 private const AGENT_STEP = 30;
13
14 public static function runAgent(int $groupId, string $newEventType, int $lastId): string
15 {
16 $runner = new self($groupId, $newEventType, $lastId);
17 [$needToContinue, $lastProcessedId] = $runner->run();
18
19 if (!$needToContinue)
20 {
21 \CCalendar::ClearCache(['event_list']);
22
23 return '';
24 }
25
26 return self::makeAgentName($groupId, $newEventType, (int)$lastProcessedId);
27 }
28
29 public function __construct(
30 public readonly int $groupId,
31 public readonly string $newEventType,
32 public readonly int $lastId,
33 )
34 {
35 }
36
37 public function run(): array
38 {
39 $toMin = time() + 12 * 3600;
40
41 $events = EventTable::query()
42 ->setSelect(['ID', 'PARENT_ID'])
43 ->where('ID', '>', $this->lastId)
44 ->where('CAL_TYPE', Dictionary::CALENDAR_TYPE['group'])
45 ->where('OWNER_ID', $this->groupId)
46 ->where('DELETED', 'N')
47 ->where('DATE_TO_TS_UTC', '>=', $toMin)
48 ->setOrder(['ID' => 'ASC'])
49 ->setLimit(self::AGENT_STEP)
50 ->fetchCollection()
51 ;
52
53 $toUpdate = [];
54 $lastProcessedId = 0;
55 foreach ($events as $event)
56 {
57 $toUpdate[] = $event->getParentId();
58 $lastProcessedId = $event->getId();
59 }
60
61 if (!empty($toUpdate))
62 {
63 EventTable::updateByFilter(['PARENT_ID' => $toUpdate], ['EVENT_TYPE' => $this->newEventType]);
64 }
65
66 $needToContinue = $events->count() === self::AGENT_STEP;
67
68 return [$needToContinue, $lastProcessedId];
69 }
70
71 public static function makeAgentName(int $groupId, string $newEventType, int $lastId = 0): string
72 {
73 $params = $groupId . ", '" . $newEventType . "', " . $lastId;
74
75 return self::class . '::runAgent(' . $params . ');';
76 }
77}
static makeAgentName(int $groupId, string $newEventType, int $lastId=0)
Определения updateeventtypeagent.php:71
static runAgent(int $groupId, string $newEventType, int $lastId)
Определения updateeventtypeagent.php:14
__construct(public readonly int $groupId, public readonly string $newEventType, public readonly int $lastId,)
Определения updateeventtypeagent.php:29
if(!\Bitrix\Main\Loader::includeModule('clouds')) $lastId
Определения sync.php:68
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$event
Определения prolog_after.php:141
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799