Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
messageaccess.php
1<?php
2
3namespace Bitrix\Mail\Item;
4
5class MessageAccess extends Base
6{
7 private const FIELD_TOKEN = 'TOKEN';
8 private const FIELD_SECRET = 'SECRET';
9 private const FIELD_MESSAGE_ID = 'MESSAGE_ID';
10 private const FIELD_MAILBOX_ID = 'MAILBOX_ID';
11 private const FIELD_ENTITY_TYPE = 'ENTITY_TYPE';
12 private const FIELD_ENTITY_ID = 'ENTITY_ID';
13 private const FIELD_ENTITY_UF_ID = 'ENTITY_UF_ID';
14 private const FIELD_ENTITY_UF_TYPE = 'ENTITY_UF_TYPE';
15 private const FIELD_ENTITY_OPTIONS = 'OPTIONS';
16
18 private $token;
20 private $secret;
22 private $messageId;
24 private $mailboxId;
26 private $entityType;
28 private $entityId;
30 private $entityUfId;
32 private $entityUfType;
34 private $options;
35
36 protected function __construct(string $token, string $secret, int $mailboxId, int $messageId)
37 {
38 $this->token = $token;
39 $this->secret = $secret;
40 $this->mailboxId = $mailboxId;
41 $this->messageId = $messageId;
42 }
43
44 public static function fromArray(array $array): self
45 {
46 if (!isset(
47 $array[self::FIELD_TOKEN],
48 $array[self::FIELD_SECRET],
49 $array[self::FIELD_MAILBOX_ID],
50 $array[self::FIELD_MESSAGE_ID]
51 ))
52 {
53 throw new \Bitrix\Main\SystemException('message access field error');
54 }
55
56 $item = new self($array[self::FIELD_TOKEN], $array[self::FIELD_SECRET], (int)$array[self::FIELD_MAILBOX_ID], (int)$array[self::FIELD_MESSAGE_ID]);
57
58 $item->entityType = $array[self::FIELD_ENTITY_TYPE] ?? '';
59 $item->entityId = (int)$array[self::FIELD_ENTITY_ID] ?? '';
60 $item->entityUfType = $array[self::FIELD_ENTITY_UF_TYPE] ?? '';
61 $item->entityUfId = (int)$array[self::FIELD_ENTITY_UF_ID] ?? '';
62 $item->options = $array[self::FIELD_ENTITY_OPTIONS] ?? '';
63
64 return $item;
65 }
66
70 public function getToken(): string
71 {
72 return $this->token;
73 }
74
78 public function getSecret(): string
79 {
80 return $this->secret;
81 }
82
86 public function getMessageId(): int
87 {
88 return $this->messageId;
89 }
90
94 public function getMailboxId(): int
95 {
96 return $this->mailboxId;
97 }
98
102 public function getEntityType(): string
103 {
104 return $this->entityType;
105 }
106
110 public function getEntityId(): int
111 {
112 return $this->entityId;
113 }
114
118 public function getEntityUfId(): int
119 {
120 return $this->entityUfId;
121 }
122
126 public function getEntityUfType(): string
127 {
128 return $this->entityUfType;
129 }
130
134 public function getOptions(): string
135 {
136 return $this->options;
137 }
138
139 public function toArray(): array
140 {
141 return [
142 self::FIELD_TOKEN => $this->getToken(),
143 self::FIELD_SECRET => $this->getSecret(),
144 self::FIELD_MESSAGE_ID => $this->getMessageId(),
145 self::FIELD_MAILBOX_ID => $this->getMailboxId(),
146 self::FIELD_ENTITY_TYPE => $this->getEntityType(),
147 self::FIELD_ENTITY_ID => $this->getEntityId(),
148 self::FIELD_ENTITY_UF_ID => $this->getEntityUfId(),
149 self::FIELD_ENTITY_UF_TYPE => $this->getEntityUfType(),
150 self::FIELD_ENTITY_OPTIONS => $this->getOptions(),
151 ];
152 }
153}
__construct(string $token, string $secret, int $mailboxId, int $messageId)
static fromArray(array $array)