1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
openeventdeleted.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\Internals\Counter\Job;
4
5use Bitrix\Calendar\Internals\Counter\CounterTable;
6use Bitrix\Calendar\Internals\Counter\Processor;
7use Bitrix\Calendar\Internals\Log\Logger;
8use Bitrix\Main\Update\Stepper;
9
14final class OpenEventDeleted extends Stepper
15{
16 private const LIMIT = 50;
17 protected static $moduleId = 'calendar';
18
19 public function execute(array &$option): bool
20 {
22 $offset = (int)($option['offset'] ?? 0);
23 $eventId = (int)($outerParams[0] ?? null);
24 $categoryId = (int)($outerParams[1] ?? null);
25
26 $userIds = $this->getAffectedUserIds(eventId: $eventId, offset: $offset);
27
28 if (empty($userIds))
29 {
30 return self::FINISH_EXECUTION;
31 }
32
33 $this
34 ->dropCounter(eventId: $eventId, categoryId: $categoryId, userIds: $userIds)
35 ->setOptions(options: $option, offset: $offset)
36 ;
37
38 return self::CONTINUE_EXECUTION;
39 }
40
41 private function getAffectedUserIds(int $eventId, int $offset): array
42 {
43 $userIds = [];
44
45 try
46 {
48 ->setSelect(['USER_ID'])
49 ->where('EVENT_ID', '=', $eventId)
50 ->setLimit($this->getLimit())
51 ->setOffset($offset)
52 ->exec()
53 ;
54
55 foreach ($query->fetchAll() as $counter)
56 {
57 $userIds[] = (int)$counter['USER_ID'];
58 }
59 }
60 catch (\Exception $exception)
61 {
62 (new Logger())->log($exception);
63 }
64
65 return $userIds;
66 }
67
68 private function dropCounter(int $eventId, int $categoryId, array $userIds): self
69 {
70 (new Processor\OpenEvent())->dropCounter(userIds: $userIds, eventId: $eventId, categoryId: $categoryId);
71
72 return $this;
73 }
74
75 private function setOptions(array &$options, int $offset): self
76 {
77 $options['offset'] = $offset + $this->getLimit();
78
79 return $this;
80 }
81
82 private function getLimit(): int
83 {
84 $limit = \COption::GetOptionString('calendar', 'calendarCounterStepperLimit', '');
85
86 return $limit === ''
87 ? self::LIMIT
88 : (int)$limit
89 ;
90 }
91}
getOuterParams()
Определения stepper.php:212
$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
$counter
Определения options.php:5
$option
Определения options.php:1711