Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
rolerelationservice.php
1
<?php
2
namespace
Bitrix\Sender\Access\Service
;
3
4
use
Bitrix\Main\Access\Exception\RoleRelationSaveException
;
5
use
Bitrix\Main\DB\SqlQueryException
;
6
use
Bitrix\Sender\Access\Role\RoleRelationTable
;
7
use
Bitrix\Sender\Access\Role\RoleUtil
;
8
9
class
RoleRelationService
implements
RoleRelationServiceInterface
10
{
15
public
function
saveRoleRelation
(array $settings): void
16
{
17
foreach
($settings as $setting)
18
{
19
$roleId = $setting[
'id'
];
20
$accessCodes = $setting[
'accessCodes'
] ?? [];
21
22
if
($roleId ===
false
)
23
{
24
continue
;
25
}
26
27
(
new
RoleUtil
($roleId))->updateRoleRelations($accessCodes);
28
}
29
}
30
34
public
function
getRolesByRelations
(array $relations): ?array
35
{
36
$senderRoleRelations = RoleRelationTable::query()
37
->setSelect([
'ROLE_ID'
])
38
->whereIn(
'RELATION'
, $relations)
39
->exec()
40
->fetchAll();
41
42
$roles = [];
43
foreach
($senderRoleRelations as $relation)
44
{
45
$roles[] = $relation[
"ROLE_ID"
];
46
}
47
48
return
$roles;
49
}
50
55
public
function
deleteRoleRelations
(
int
$roleId): void
56
{
57
if
(!RoleRelationTable::deleteList([
"=ROLE_ID"
=> $roleId]))
58
{
59
throw
new
SqlQueryException
();
60
}
61
}
62
66
public
function
getRelationList
(array $parameters = []): ?array
67
{
68
return
RoleRelationTable::getList($parameters)->fetchAll();
69
}
70
}
Bitrix\Main\Access\Exception\RoleRelationSaveException
Definition
rolerelationsaveexception.php:12
Bitrix\Main\DB\SqlQueryException
Definition
sqlexception.php:24
Bitrix\Sender\Access\Role\RoleRelationTable
Definition
rolerelation.php:30
Bitrix\Sender\Access\Role\RoleUtil
Definition
roleutil.php:20
Bitrix\Sender\Access\Service\RoleRelationService
Definition
rolerelationservice.php:10
Bitrix\Sender\Access\Service\RoleRelationService\getRolesByRelations
getRolesByRelations(array $relations)
Definition
rolerelationservice.php:34
Bitrix\Sender\Access\Service\RoleRelationService\saveRoleRelation
saveRoleRelation(array $settings)
Definition
rolerelationservice.php:15
Bitrix\Sender\Access\Service\RoleRelationService\deleteRoleRelations
deleteRoleRelations(int $roleId)
Definition
rolerelationservice.php:55
Bitrix\Sender\Access\Service\RoleRelationService\getRelationList
getRelationList(array $parameters=[])
Definition
rolerelationservice.php:66
Bitrix\Sender\Access\Service\RoleRelationServiceInterface
Definition
rolerelationserviceinterface.php:6
Bitrix\Sender\Access\Service
Definition
roledealcategoryservice.php:2
modules
sender
lib
access
service
rolerelationservice.php
Создано системой
1.10.0