Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
VariableRule.php
1
<?php
2
3
namespace
Bitrix\Catalog\Access\Rule
;
4
5
use
Bitrix\Catalog\Access\Permission\PermissionDictionary
;
6
use
Bitrix\Catalog\Config\Feature
;
7
22
class
VariableRule
extends
BaseRule
23
{
24
public
function
getPermissionMultiValues
($params): ?array
25
{
26
if
(!Feature::isAccessControllerCheckingEnabled())
27
{
28
return
[$this->
getAllValue
()];
29
}
30
31
$permissionCode = static::getPermissionCode($params);
32
33
$values = $this->user->getPermissionMulti($permissionCode);
34
return
$values ? array_intersect($values, $this->
getAvailableValues
()):
null
;
35
}
36
37
protected
function
getAvailableValues
(): array
38
{
39
$values = $this->
loadAvailableValues
();
40
$values[] = $this->
getAllValue
();
41
42
return
$values;
43
}
44
45
protected
function
loadAvailableValues
(): array
46
{
47
return
[];
48
}
49
50
protected
function
getAllValue
(): int
51
{
52
return
PermissionDictionary::VALUE_VARIATION_ALL;
53
}
54
55
protected
function
check
($params): bool
56
{
58
$values = $this->
getPermissionMultiValues
($params);
59
if
(!$values)
60
{
61
return
false
;
62
}
63
64
if
(
65
(!isset($params[
'value'
]) && !empty($values))
66
|| in_array($this->
getAllValue
(), $values,
true
)
67
)
68
{
69
return
true
;
70
}
71
72
$checkStoreIds = (array)($params[
'value'
] ?? []);
73
74
return
empty(
75
array_diff($checkStoreIds, $values)
76
);
77
}
78
}
Bitrix\Catalog\Access\Permission\PermissionDictionary
Definition
PermissionDictionary.php:21
Bitrix\Catalog\Access\Rule\BaseRule
Definition
BaseRule.php:13
Bitrix\Catalog\Access\Rule\BaseRule\check
check($params)
Definition
BaseRule.php:73
Bitrix\Catalog\Access\Rule\VariableRule
Definition
VariableRule.php:23
Bitrix\Catalog\Access\Rule\VariableRule\getPermissionMultiValues
getPermissionMultiValues($params)
Definition
VariableRule.php:24
Bitrix\Catalog\Access\Rule\VariableRule\getAllValue
getAllValue()
Definition
VariableRule.php:50
Bitrix\Catalog\Access\Rule\VariableRule\getAvailableValues
getAvailableValues()
Definition
VariableRule.php:37
Bitrix\Catalog\Access\Rule\VariableRule\loadAvailableValues
loadAvailableValues()
Definition
VariableRule.php:45
Bitrix\Catalog\Config\Feature
Definition
feature.php:16
Bitrix\Catalog\Access\Rule
Definition
BaseRule.php:3
modules
catalog
lib
Access
Rule
VariableRule.php
Создано системой
1.10.0