Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
link.php
1<?php
3
6
7abstract class Link implements EntityInterface
8{
9 public const SHARING_PUBLIC_PATH = 'pub/calendar-sharing';
10
11 protected int $id;
12 protected int $objectId;
13 protected string $hash;
14 protected bool $active;
15 protected ?DateTime $dateCreate = null;
16 protected ?DateTime $dateExpire = null;
17 protected ?int $frequentUse = null;
18
22 public function getId(): ?int
23 {
24 return $this->id ?? null;
25 }
26
31 public function setId(int $id): self
32 {
33 $this->id = $id;
34
35 return $this;
36 }
37
41 public function getObjectId(): int
42 {
43 return $this->objectId;
44 }
45
50 public function setObjectId(int $objectId): self
51 {
52 $this->objectId = $objectId;
53
54 return $this;
55 }
56
60 public function isActive(): bool
61 {
62 return $this->active;
63 }
64
69 public function setActive(bool $active): self
70 {
71 $this->active = $active;
72
73 return $this;
74 }
75
79 public function getDateCreate(): ?DateTime
80 {
81 return $this->dateCreate;
82 }
83
88 public function setDateCreate(DateTime $dateCreate): self
89 {
90 $this->dateCreate = $dateCreate;
91
92 return $this;
93 }
94
98 public function getDateExpire(): ?DateTime
99 {
100 return $this->dateExpire;
101 }
102
107 public function setDateExpire(?DateTime $dateExpire): self
108 {
109 $this->dateExpire = $dateExpire;
110
111 return $this;
112 }
113
117 public function getFrequentUse(): ?int
118 {
119 return $this->frequentUse;
120 }
121
126 public function setFrequentUse(?int $frequentUse): self
127 {
128 $this->frequentUse = $frequentUse;
129
130 return $this;
131 }
132
133 public function getHash(): string
134 {
135 if (empty($this->hash))
136 {
137 $this->hash = $this->generateHash();
138 }
139
140 return $this->hash;
141 }
142
143 public function setHash(string $hash): self
144 {
145 $this->hash = $hash;
146
147 return $this;
148 }
149
150 public function getUrl(): string
151 {
152 $serverPath = \CCalendar::GetServerPath();
153 $publicPath = self::SHARING_PUBLIC_PATH;
154 $hash = $this->getHash();
155
156 return "$serverPath/$publicPath/$hash/";
157 }
158
159 public function generateHash(): string
160 {
161 return hash('sha256', $this->objectId . $this->getObjectType() . microtime() . \CMain::getServerUniqID());
162 }
163
164 public function isJoint(): bool
165 {
166 return false;
167 }
168
169 abstract public function getObjectType(): string;
170}