Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
RoleRelationService.php
1
<?php
2
namespace
Bitrix\Catalog\Access\Service
;
3
4
use
Bitrix\Main\Access\Exception\RoleRelationSaveException
;
5
use
Bitrix\Main\DB\SqlQueryException
;
6
use
Bitrix\Catalog\Access\Role\RoleRelationTable
;
7
use
Bitrix\Catalog\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\Catalog\Access\Role\RoleRelationTable
Definition
RoleRelationTable.php:30
Bitrix\Catalog\Access\Role\RoleUtil
Definition
RoleUtil.php:15
Bitrix\Catalog\Access\Service\RoleRelationService
Definition
RoleRelationService.php:10
Bitrix\Catalog\Access\Service\RoleRelationService\getRolesByRelations
getRolesByRelations(array $relations)
Definition
RoleRelationService.php:34
Bitrix\Catalog\Access\Service\RoleRelationService\saveRoleRelation
saveRoleRelation(array $settings)
Definition
RoleRelationService.php:15
Bitrix\Catalog\Access\Service\RoleRelationService\deleteRoleRelations
deleteRoleRelations(int $roleId)
Definition
RoleRelationService.php:55
Bitrix\Catalog\Access\Service\RoleRelationService\getRelationList
getRelationList(array $parameters=[])
Definition
RoleRelationService.php:66
Bitrix\Main\Access\Exception\RoleRelationSaveException
Definition
rolerelationsaveexception.php:12
Bitrix\Main\DB\SqlQueryException
Definition
sqlexception.php:24
Bitrix\Catalog\Access\Service\RoleRelationServiceInterface
Definition
RoleRelationServiceInterface.php:6
Bitrix\Catalog\Access\Service
Definition
RolePermissionService.php:2
modules
catalog
lib
Access
Service
RoleRelationService.php
Создано системой
1.10.0