Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
RoleUtil.php
1<?php
10
13
15{
16
17 protected static function getRoleTableClass(): string
18 {
19 return RoleTable::class;
20 }
21
22 protected static function getRoleRelationTableClass(): string
23 {
24 return RoleRelationTable::class;
25 }
26
27 protected static function getPermissionTableClass(): string
28 {
29 return PermissionTable::class;
30 }
31
32 protected static function getRoleDictionaryClass(): ?string
33 {
34 return RoleDictionary::class;
35 }
36
43 public static function insertPermissions(array $valuesData): void
44 {
45 if (empty($valuesData))
46 {
47 return;
48 }
49
50 $connection = \Bitrix\Main\Application::getConnection();
51 $helper = $connection->getSqlHelper();
52
53 $query = '
54 INSERT INTO b_catalog_permission
55 (ROLE_ID, PERMISSION_ID, ' . $helper->quote('VALUE') . ')
56 VALUES ' . implode(',', $valuesData)
57 ;
58
59 $connection->query($query);
60 }
61
62 public function getPermissions(): array
63 {
64 $class = static::getPermissionTableClass();
65
66 return $class::getList([
67 'filter' => [
68 '=ROLE_ID' => $this->roleId,
69 ],
70 'select' => ['PERMISSION_ID', 'VALUE']
71 ])
72 ->fetchAll()
73 ;
74 }
75}
static insertPermissions(array $valuesData)
Definition RoleUtil.php:43