1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
AbstractJob.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
6
13
14abstract class AbstractJob implements Arrayable
15{
16 #[PositiveNumber]
17 protected int $collabId;
18 #[PositiveNumber]
19 protected int $userId;
20 #[PositiveNumber]
21 protected ?int $id;
22
23 protected Type $type;
24 protected ?DateTime $createdDate = null;
26
27 protected const SECONDS_PER_DAY = 60 * 60 * 24;
28
29 public function __construct(int $collabId, int $userId)
30 {
31 $this->collabId = $collabId;
32 $this->userId = $userId;
33 $this->type = $this->getType();
34 $this->nextExecution = $this->createNextExecutionDate();
35 }
36
37 // Can be executed immediately upon the execution date.
38 // (Immediately) example: sending a system message
39 // (Not immediately) example: showing the aha-moment when a person enters the chat
40 abstract public function isImmediatelyExecuted(): bool;
41 abstract public function getType(): Type;
42 abstract protected function createNextExecutionDate(): DateTime;
43
44 public function __invoke(): JobResult
45 {
46 return new JobResult();
47 }
48
49 public function getId(): ?int
50 {
51 return $this->id ?? null;
52 }
53
54 public function getUserId(): int
55 {
56 return $this->userId;
57 }
58
59 public function getChatId(): ?int
60 {
61 $collab = CollabRegistry::getInstance()->get($this->collabId);
62
63 return $collab?->getChatId();
64 }
65
66 public function getCollabId(): int
67 {
68 return $this->collabId;
69 }
70
71 public function getCreatedDate(): ?DateTime
72 {
73 return $this->createdDate;
74 }
75
76 public function getNextExecution(): DateTime
77 {
79 }
80
81 public function setId(int $id): static
82 {
83 $this->id = $id;
84
85 return $this;
86 }
87
88 public function setCreatedDate(DateTime $createdDate): static
89 {
90 $this->createdDate = $createdDate;
91
92 return $this;
93 }
94
95 public function setNextExecution(DateTime $nextExecution): static
96 {
97 $this->nextExecution = $nextExecution;
98
99 return $this;
100 }
101
102 public function toArray(): array
103 {
104 return [
105 'collabId' => $this->getCollabId(),
106 'userId' => $this->getUserId(),
107 'id' => $this->getId(),
108 'type' => $this->getType()->value,
109 'createdDate' => $this->getCreatedDate(),
110 'nextExecution' => $this->getNextExecution(),
111 ];
112 }
113}
setNextExecution(DateTime $nextExecution)
Определения AbstractJob.php:95
__construct(int $collabId, int $userId)
Определения AbstractJob.php:29
setCreatedDate(DateTime $createdDate)
Определения AbstractJob.php:88
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804