Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
ContextCustomer.php
1
<?php
2
3
namespace
Bitrix\Im\V2\Common
;
4
5
use
Bitrix\Im\User
;
6
use
Bitrix\Im\V2\Service\Context
;
7
11
trait ContextCustomer
12
{
13
protected
?
Context
$context =
null
;
14
20
public
function
withContext
(?
Context
$context): self
21
{
22
$copy = clone $this;
23
24
return
$copy->setContext($context);
25
}
26
32
public
function
withContextUser
($user): self
33
{
34
if
($this->context)
35
{
36
$context = clone $this->context;
37
}
38
else
39
{
40
$context =
new
Context
;
41
}
42
43
if
($user instanceof
User
)
44
{
45
$context->
setUser
($user);
46
}
47
elseif (is_numeric($user))
48
{
49
$context->
setUserId
((
int
)$user);
50
}
51
52
return
$this->
withContext
($context);
53
}
54
60
public
function
setContext
(?
Context
$context): self
61
{
62
$this->context = $context;
63
64
return
$this;
65
}
66
71
public
function
getContext
():
Context
72
{
73
if
($this->context)
74
{
75
return
$this->context;
76
}
77
78
return \Bitrix\Im\V2\Service\Locator::getContext();
79
}
80
}
Bitrix\Im\User
Definition
user.php:10
Bitrix\Im\V2\Service\Context
Definition
Context.php:8
Bitrix\Im\V2\Service\Context\setUserId
setUserId(?int $contextUserId)
Definition
Context.php:41
Bitrix\Im\V2\Service\Context\setUser
setUser($contextUser)
Definition
Context.php:16
Bitrix\Im\V2\Common
Definition
ActiveRecordImplementation.php:3
Bitrix\Im\V2\Common\withContext
withContext(?Context $context)
Definition
ContextCustomer.php:20
Bitrix\Im\V2\Common\withContextUser
withContextUser($user)
Definition
ContextCustomer.php:32
Bitrix\Im\V2\Common\getContext
getContext()
Definition
ContextCustomer.php:71
Bitrix\Im\V2\Common\setContext
setContext(?Context $context)
Definition
ContextCustomer.php:60
modules
im
lib
V2
Common
ContextCustomer.php
Создано системой
1.10.0