Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
Context.php
1
<?php
2
3
namespace
Bitrix\Im\V2\Service
;
4
5
use
Bitrix\Im\V2\Entity\User\User
;
6
7
class
Context
8
{
9
protected
?
int
$actionContextUserId
=
null
;
10
16
public
function
setUser
($contextUser): self
17
{
18
if
(is_numeric($contextUser))
19
{
20
$this->
setUserId
((
int
)$contextUser);
21
}
22
elseif ($contextUser instanceof
User
)
23
{
24
$this->
setUserId
($contextUser->getId());
25
}
26
elseif ($contextUser ===
null
)
27
{
28
$this->
resetUser
();
29
}
30
31
return
$this;
32
}
33
41
public
function
setUserId
(?
int
$contextUserId): self
42
{
43
if
(is_numeric($contextUserId))
44
{
45
$this->actionContextUserId = (int)$contextUserId;
46
}
47
elseif ($contextUserId ===
null
)
48
{
49
$this->
resetUser
();
50
}
51
52
return
$this;
53
}
54
59
public
function
resetUser
(): self
60
{
61
$this->actionContextUserId =
null
;
62
63
return
$this;
64
}
65
70
public
function
getUserId
(): int
71
{
72
global $USER;
73
if
(
74
$this->actionContextUserId ===
null
75
&& ($USER instanceof \CUser)
76
)
77
{
78
return
(
int
)$USER->getId();
79
}
80
81
return
(
int
)$this->actionContextUserId;
82
}
83
88
public
function
getUser
():
User
89
{
90
return
User::getInstance($this->
getUserId
());
91
}
92
}
Bitrix\Im\User
Definition
user.php:10
Bitrix\Im\V2\Entity\User\User
Definition
User.php:24
Bitrix\Im\V2\Service\Context
Definition
Context.php:8
Bitrix\Im\V2\Service\Context\getUserId
getUserId()
Definition
Context.php:70
Bitrix\Im\V2\Service\Context\setUserId
setUserId(?int $contextUserId)
Definition
Context.php:41
Bitrix\Im\V2\Service\Context\$actionContextUserId
int $actionContextUserId
Definition
Context.php:9
Bitrix\Im\V2\Service\Context\setUser
setUser($contextUser)
Definition
Context.php:16
Bitrix\Im\V2\Service\Context\resetUser
resetUser()
Definition
Context.php:59
Bitrix\Im\V2\Service\Context\getUser
getUser()
Definition
Context.php:88
Bitrix\Im\V2\Service
Definition
Context.php:3
modules
im
lib
V2
Service
Context.php
Создано системой
1.10.0