1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
QueueItem.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Recent\Initializer\Queue;
4
5use Bitrix\Im\Model\RecentInitQueueTable;
6use Bitrix\Im\V2\Recent\Initializer\SourceType;
7use Bitrix\Im\V2\Recent\Initializer\StageType;
8use Bitrix\Main\Type\DateTime;
9
11{
12 public function __construct(
13 public readonly int $id,
14 public readonly int $userId,
15 public readonly StageType $stageType,
16 public readonly SourceType $sourceType,
17 public readonly ?int $sourceId,
18 public readonly string $pointer,
19 public readonly string $status,
20 public readonly bool $isLocked,
21 public readonly DateTime $dateCreate,
22 public readonly DateTime $dateUpdate,
23 public readonly bool $isFirstInit
24 ){}
25
26 public static function createFromRow(array $row): static
27 {
28 return new static(
29 (int)$row['ID'],
30 (int)$row['USER_ID'],
31 StageType::tryFrom($row['STAGE'] ?? null) ?? StageType::Target,
32 SourceType::tryFrom($row['SOURCE'] ?? null) ?? SourceType::Collab,
33 isset($row['SOURCE_ID']) ? (int)$row['SOURCE_ID'] : null,
34 $row['POINTER'],
35 $row['STATUS'],
36 $row['IS_LOCKED'] === 'Y',
37 $row['DATE_CREATE'],
38 $row['DATE_UPDATE'],
39 false,
40 );
41 }
42
43 public static function createFirstStep(int $userId, SourceType $sourceType, ?int $sourceId, bool $isFirstInit = false): static
44 {
45 $currentDate = new DateTime();
46
47 return new static(
48 0,
49 $userId,
50 StageType::getFirst(),
51 $sourceType,
52 $sourceId,
53 '',
54 '',
55 false,
56 $currentDate,
57 $currentDate,
58 $isFirstInit
59 );
60 }
61
62 public function setId(int $id): self
63 {
64 return $this->copy(id: $id);
65 }
66
67 public function lock(): self
68 {
69 RecentInitQueueTable::update($this->id, ['IS_LOCKED' => true, 'DATE_UPDATE' => new DateTime()]);
70
71 return $this->copy(isLocked: true);
72 }
73
74 public function unlock(bool $withSave = false): self
75 {
76 if ($withSave)
77 {
78 RecentInitQueueTable::update($this->id, ['IS_LOCKED' => false, 'DATE_UPDATE' => new DateTime()]);
79 }
80
81 return $this->copy(isLocked: false);
82 }
83
84 public function setErrorStatus(): self
85 {
86 return $this->copy(status: 'ERROR', dateUpdate: new DateTime());
87 }
88
89 public function updatePointer(string $pointer, ?StageType $stage = null): self
90 {
91 return $this->copy(stageType: $stage, pointer: $pointer, status: '', dateUpdate: new DateTime());
92 }
93
94 public function getFields(): array
95 {
96 return [
97 'ID' => $this->id,
98 'USER_ID' => $this->userId,
99 'STAGE' => $this->stageType->value,
100 'SOURCE' => $this->sourceType->value,
101 'SOURCE_ID' => $this->sourceId,
102 'POINTER' => $this->pointer,
103 'STATUS' => $this->status,
104 'IS_LOCKED' => $this->isLocked,
105 'DATE_CREATE' => $this->dateCreate,
106 'DATE_UPDATE' => $this->dateUpdate,
107 ];
108 }
109
110 protected function copy(
111 ?int $id = null,
112 ?int $userId = null,
113 ?StageType $stageType = null,
114 ?SourceType $sourceType = null,
115 ?int $sourceId = null,
116 ?string $pointer = null,
117 ?string $status = null,
118 ?bool $isLocked = null,
119 ?DateTime $dateCreate = null,
120 ?DateTime $dateUpdate = null,
121 ?bool $isFirstInit = null,
122 ): self
123 {
124 return new static(
125 $id ?? $this->id,
127 $stageType ?? $this->stageType,
128 $sourceType ?? $this->sourceType,
129 $sourceId ?? $this->sourceId,
130 $pointer ?? $this->pointer,
132 $isLocked ?? $this->isLocked,
133 $dateCreate ?? $this->dateCreate,
134 $dateUpdate ?? $this->dateUpdate,
135 $isFirstInit ?? $this->isFirstInit,
136 );
137 }
138}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
copy(?int $id=null, ?int $userId=null, ?StageType $stageType=null, ?SourceType $sourceType=null, ?int $sourceId=null, ?string $pointer=null, ?string $status=null, ?bool $isLocked=null, ?DateTime $dateCreate=null, ?DateTime $dateUpdate=null, ?bool $isFirstInit=null,)
Определения QueueItem.php:110
static createFromRow(array $row)
Определения QueueItem.php:26
unlock(bool $withSave=false)
Определения QueueItem.php:74
__construct(public readonly int $id, public readonly int $userId, public readonly StageType $stageType, public readonly SourceType $sourceType, public readonly ?int $sourceId, public readonly string $pointer, public readonly string $status, public readonly bool $isLocked, public readonly DateTime $dateCreate, public readonly DateTime $dateUpdate, public readonly bool $isFirstInit)
Определения QueueItem.php:12
static createFirstStep(int $userId, SourceType $sourceType, ?int $sourceId, bool $isFirstInit=false)
Определения QueueItem.php:43
updatePointer(string $pointer, ?StageType $stage=null)
Определения QueueItem.php:89
static update($primary, array $data)
Определения datamanager.php:1256
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$status
Определения session.php:10