Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Context.php
1<?php
2
4
7
8class Context
9{
10 protected const FACE_WEB = 'web';
11 protected const FACE_MOBILE = 'mob';
12 protected const FACE_REST = 'rest';
13 protected const FACE_BIZPROC = 'bizproc';
14
15 protected string $face = self::FACE_WEB;
16 protected string $moduleId = 'bizproc';
17 protected int $userId;
18 protected bool $isManual = false;
19
20 public function setFace(string $face): self
21 {
22 $this->face = $face;
23
24 return $this;
25 }
26
27 public function setModuleId(string $moduleId): self
28 {
29 $this->moduleId = $moduleId;
30
31 return $this;
32 }
33
34 public function setUserId(int $userId): self
35 {
36 $this->userId = $userId;
37
38 return $this;
39 }
40
41 public function setIsManual(): self
42 {
43 $this->isManual = true;
44 $this->setUserIdFromCurrent();
45
46 return $this;
47 }
48
49 protected function setUserIdFromCurrent(): self
50 {
51 $id = CurrentUser::get()->getId();
52 $this->setUserId((int)$id);
53
54 return $this;
55 }
56
57 public function isManualOperation(): bool
58 {
59 return $this->isManual;
60 }
61}