Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
ChatTypeFilter.php
1
<?php
2
3
namespace
Bitrix\Im\V2\Controller\Filter
;
4
5
use
Bitrix\Im\V2\Chat\ChatError
;
6
use
Bitrix\Main\Engine\ActionFilter\Base
;
7
use
Bitrix\Main\Event
;
8
use
Bitrix\Main\EventResult
;
9
10
class
ChatTypeFilter
extends
Base
11
{
12
private
array $types;
13
private
bool
$isAllowed;
14
15
public
function
__construct
(array $types,
bool
$isAllowed =
true
)
16
{
17
parent::__construct();
18
$this->types = $types;
19
$this->isAllowed = $isAllowed;
20
}
21
22
public
function
onBeforeAction
(
Event
$event)
23
{
24
$chat = $this->
getAction
()->getArguments()[
'chat'
] ??
null
;
25
if
($this->isAllowed)
26
{
27
foreach
($this->types as $type)
28
{
29
if
($chat instanceof $type)
30
{
31
return
null
;
32
}
33
}
34
35
$this->
addError
(
new
ChatError
(
ChatError::WRONG_TYPE
));
36
37
return
new
EventResult
(EventResult::ERROR,
null
,
null
, $this);
38
}
39
40
foreach
($this->types as $type)
41
{
42
if
($chat instanceof $type)
43
{
44
$this->
addError
(
new
ChatError
(
ChatError::WRONG_TYPE
));
45
46
return
new
EventResult
(EventResult::ERROR,
null
,
null
, $this);
47
}
48
}
49
50
return
null
;
51
}
52
}
Bitrix\Im\V2\Chat\ChatError
Definition
ChatError.php:9
Bitrix\Im\V2\Chat\ChatError\WRONG_TYPE
const WRONG_TYPE
Definition
ChatError.php:11
Bitrix\Im\V2\Controller\Filter\ChatTypeFilter
Definition
ChatTypeFilter.php:11
Bitrix\Im\V2\Controller\Filter\ChatTypeFilter\onBeforeAction
onBeforeAction(Event $event)
Definition
ChatTypeFilter.php:22
Bitrix\Im\V2\Controller\Filter\ChatTypeFilter\__construct
__construct(array $types, bool $isAllowed=true)
Definition
ChatTypeFilter.php:15
Bitrix\Im\V2\Sync\Event
Definition
Event.php:9
Bitrix\Main\Engine\ActionFilter\Base
Definition
base.php:15
Bitrix\Main\Engine\ActionFilter\Base\addError
addError(Error $error)
Definition
base.php:80
Bitrix\Main\Engine\ActionFilter\Base\getAction
getAction()
Definition
base.php:48
Bitrix\Main\Event
Definition
event.php:5
Bitrix\Main\EventResult
Definition
eventresult.php:5
Bitrix\Im\V2\Controller\Filter
Definition
ActionUuidHandler.php:3
modules
im
lib
V2
Controller
Filter
ChatTypeFilter.php
Создано системой
1.10.0