Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
rowtype.php
1
<?php
2
3
namespace
Bitrix\Iblock\Grid
;
4
5
use
Bitrix\Main\SystemException
;
6
7
class
RowType
8
{
9
public
const
ELEMENT
=
'E'
;
10
public
const
SECTION
=
'S'
;
11
17
public
static
function
getIndex
(
string
$type,
string
|
int
$id): string
18
{
19
return
($type === self::SECTION ? self::SECTION :
self::ELEMENT
) . $id;
20
}
21
27
public
static
function
parseIndex
(
string
$index): ?array
28
{
29
$re =
'/^(E|S|)(\d+)$/'
;
30
if
(preg_match($re, $index, $m))
31
{
32
$type = ($m[1] ?:
RowType::ELEMENT
);
33
$index = (int)$m[2];
34
35
return
[$type, $index];
36
}
37
elseif (is_numeric($index))
38
{
39
return
[
RowType::ELEMENT
, (int)$index];
40
}
41
42
return
null
;
43
}
44
52
public
static
function
parseIndexList
(array $ids): array
53
{
54
$elementIds = [];
55
$sectionIds = [];
56
57
foreach
($ids as $id)
58
{
59
$index =
self::parseIndex
($id);
60
if
($index ===
null
)
61
{
62
continue
;
63
}
64
[$type, $id] = $index;
65
66
if
($type === self::ELEMENT)
67
{
68
$elementIds[] = $id;
69
}
70
else
71
{
72
$sectionIds[] = $id;
73
}
74
}
75
76
return
[$elementIds, $sectionIds];
77
}
78
}
Bitrix\Iblock\Grid\RowType
Definition
rowtype.php:8
Bitrix\Iblock\Grid\RowType\parseIndexList
static parseIndexList(array $ids)
Definition
rowtype.php:52
Bitrix\Iblock\Grid\RowType\ELEMENT
const ELEMENT
Definition
rowtype.php:9
Bitrix\Iblock\Grid\RowType\getIndex
static getIndex(string $type, string|int $id)
Definition
rowtype.php:17
Bitrix\Iblock\Grid\RowType\SECTION
const SECTION
Definition
rowtype.php:10
Bitrix\Iblock\Grid\RowType\parseIndex
static parseIndex(string $index)
Definition
rowtype.php:27
Bitrix\Main\SystemException
Definition
exception.php:8
Bitrix\Iblock\Grid
modules
iblock
lib
grid
rowtype.php
Создано системой
1.10.0