1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
CheckNotifyGroupAccess.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Im\V2\Controller\Filter;
4
5
use Bitrix\Im\V2\Notification\Group\UserGroup\Dto\ConditionDto;
6
use Bitrix\Im\V2\Notification\Group\UserGroup\Dto\UserGroupDto;
7
use Bitrix\Im\V2\Notification\Group\UserGroup\GroupRepository;
8
use Bitrix\Im\V2\Notification\NotifyError;
9
use Bitrix\Main\Event;
10
use Bitrix\Main\EventResult;
11
use Bitrix\Main\Engine\ActionFilter\Base;
12
13
class
CheckNotifyGroupAccess
extends
Base
14
{
15
private
readonly
GroupRepository
$groupRepository;
16
17
public
function
__construct
()
18
{
19
parent::__construct();
20
$this->groupRepository =
new
GroupRepository
();
21
}
22
23
public
function
onBeforeAction
(
Event
$event
): ?
EventResult
24
{
25
if
($this->isNotFound())
26
{
27
$this->
addError
(
new
NotifyError
(
NotifyError::GROUP_NOT_FOUND
));
28
29
return
new
EventResult
(EventResult::ERROR,
null
,
null
, $this);
30
}
31
32
return
null
;
33
}
34
35
private
function
isNotFound(): bool
36
{
37
foreach
($this->
getAction
()->getArguments() as $argument)
38
{
39
if
($argument instanceof
UserGroupDto
|| $argument instanceof
ConditionDto
)
40
{
41
$exists = $this->groupRepository->isExistsWithUserId($argument->groupId, $argument->userId);
42
43
return
$exists ===
false
;
44
}
45
}
46
47
return
false
;
48
}
49
}
Bitrix\Im\V2\Controller\Filter\CheckNotifyGroupAccess
Определения
CheckNotifyGroupAccess.php:14
Bitrix\Im\V2\Controller\Filter\CheckNotifyGroupAccess\__construct
__construct()
Определения
CheckNotifyGroupAccess.php:17
Bitrix\Im\V2\Controller\Filter\CheckNotifyGroupAccess\onBeforeAction
onBeforeAction(Event $event)
Определения
CheckNotifyGroupAccess.php:23
Bitrix\Im\V2\Notification\Group\UserGroup\Dto\ConditionDto
Определения
ConditionDto.php:9
Bitrix\Im\V2\Notification\Group\UserGroup\Dto\UserGroupDto
Определения
UserGroupDto.php:6
Bitrix\Im\V2\Notification\Group\UserGroup\GroupRepository
Определения
GroupRepository.php:19
Bitrix\Im\V2\Notification\NotifyError
Определения
NotifyError.php:9
Bitrix\Im\V2\Notification\NotifyError\GROUP_NOT_FOUND
const GROUP_NOT_FOUND
Определения
NotifyError.php:10
Bitrix\Main\Engine\ActionFilter\Base
Определения
base.php:15
Bitrix\Main\Engine\ActionFilter\Base\addError
addError(Error $error)
Определения
base.php:80
Bitrix\Main\Engine\ActionFilter\Base\getAction
getAction()
Определения
base.php:48
Bitrix\Main\EventResult
Определения
eventresult.php:5
Bitrix\Im\V2\Chat\ExternalChat\Event
Определения
AfterCreateEvent.php:3
$event
$event
Определения
prolog_after.php:141
bitrix
modules
im
lib
V2
Controller
Filter
CheckNotifyGroupAccess.php
Создано системой
1.14.0