Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
StoreDocumentElement.php
1
<?php
2
3
namespace
Bitrix\Catalog\Access\Model
;
4
5
use
Bitrix\Catalog\StoreDocumentElementTable
;
6
use
Bitrix\Main\Access\AccessibleItem
;
7
8
class
StoreDocumentElement
implements
AccessibleItem
9
{
10
private
int
$id;
14
private
array $storeIds;
15
20
public
function
__construct
(
int
$id, array $storeIds = [])
21
{
22
$this->
id
= $id;
23
$this->storeIds = array_unique(
24
array_map(
'intval'
, $storeIds)
25
);
26
}
27
28
private
static
function
getStoresById(
int
$id): array
29
{
30
$storeIds = [];
31
32
if
($id > 0)
33
{
34
$row =
StoreDocumentElementTable::getRow
([
35
'select'
=> [
36
'STORE_TO'
,
37
'STORE_FROM'
,
38
],
39
'filter'
=> [
40
'=ID'
=> $id,
41
],
42
]);
43
if
($row)
44
{
45
if
(isset($row[
'STORE_TO'
]))
46
{
47
$storeIds[] = $row[
'STORE_TO'
];
48
}
49
50
if
(isset($row[
'STORE_FROM'
]))
51
{
52
$storeIds[] = $row[
'STORE_FROM'
];
53
}
54
}
55
}
56
57
return
$storeIds;
58
}
59
68
public
static
function
createFromId
(
int
$itemId, ?array $storeIds =
null
):
StoreDocumentElement
69
{
70
return
new
static
(
71
$itemId,
72
$storeIds ?? self::getStoresById($itemId)
73
);
74
}
75
83
public
static
function
createFromArray
(array $fields):
StoreDocumentElement
84
{
85
$id = (int)($fields[
'ID'
] ?? 0);
86
$storeIds = [];
87
88
if
(isset($fields[
'STORE_TO'
]))
89
{
90
$storeIds[] = $fields[
'STORE_TO'
];
91
}
92
93
if
(isset($fields[
'STORE_FROM'
]))
94
{
95
$storeIds[] = $fields[
'STORE_FROM'
];
96
}
97
98
array_push($storeIds, ... self::getStoresById($id));
99
100
return
new
static
($id, $storeIds);
101
}
102
106
public
function
getId
(): int
107
{
108
return
$this->id;
109
}
110
116
public
function
getStoreIds
(): array
117
{
118
return
$this->storeIds;
119
}
120
}
Bitrix\Catalog\Access\Model\StoreDocumentElement
Definition
StoreDocumentElement.php:9
Bitrix\Catalog\Access\Model\StoreDocumentElement\getId
getId()
Definition
StoreDocumentElement.php:106
Bitrix\Catalog\Access\Model\StoreDocumentElement\__construct
__construct(int $id, array $storeIds=[])
Definition
StoreDocumentElement.php:20
Bitrix\Catalog\Access\Model\StoreDocumentElement\createFromArray
static createFromArray(array $fields)
Definition
StoreDocumentElement.php:83
Bitrix\Catalog\Access\Model\StoreDocumentElement\getStoreIds
getStoreIds()
Definition
StoreDocumentElement.php:116
Bitrix\Catalog\Access\Model\StoreDocumentElement\createFromId
static createFromId(int $itemId, ?array $storeIds=null)
Definition
StoreDocumentElement.php:68
Bitrix\Catalog\StoreDocumentElementTable
Definition
storedocumentelementtable.php:50
Bitrix\Main\ORM\Data\DataManager\getRow
static getRow(array $parameters)
Definition
datamanager.php:410
Bitrix\Main\Access\AccessibleItem
Definition
accessibleitem.php:13
Bitrix\Catalog\Access\Model
Definition
StoreDocument.php:3
modules
catalog
lib
Access
Model
StoreDocumentElement.php
Создано системой
1.10.0