Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
columnfactory.php
1
<?php
2
3
namespace
Bitrix\Main\Grid\Column\Factory
;
4
5
use
Bitrix\Main\Grid\Column\Column
;
6
use
Bitrix\Main\Grid\Column\Editable\Factory\ConfigFactory
;
7
use
Bitrix\Main\Grid\Column\Type
;
8
9
class
ColumnFactory
10
{
11
private
ConfigFactory
$editableConfigFactory;
12
13
public
function
__construct
()
14
{
15
$this->editableConfigFactory =
new
ConfigFactory
;
16
}
17
18
public
function
createFromArray
(array $params): ?
Column
19
{
20
if
(!isset($params[
'id'
]))
21
{
22
return
null
;
23
}
24
25
$id = $params[
'id'
];
26
27
$editable = $params[
'editable'
] ??
null
;
28
if
(is_array($editable))
29
{
30
$editable[
'NAME'
] ??= $id;
31
$editable[
'TYPE'
] ??= Type::getEditorType(
32
(
string
)($params[
'type'
] ??
''
)
33
);
34
$params[
'editable'
] = $this->editableConfigFactory->createFromArray($editable) ??
false
;
35
}
36
37
if
(isset($params[
'width'
]))
38
{
39
if
(is_string($params[
'width'
]))
40
{
41
$re =
'/^(\d+)px/'
;
42
if
(preg_match($re, $params[
'width'
], $m))
43
{
44
$params[
'width'
] = (int)$m[1];
45
}
46
elseif (is_numeric($params[
'width'
]))
47
{
48
$params[
'width'
] = (int)$params[
'width'
];
49
}
50
else
51
{
52
$params[
'width'
] =
null
;
53
}
54
}
55
}
56
57
// empty string and `false` convert to `null`
58
if
(isset($params[
'sort'
]) && empty($params[
'sort'
]))
59
{
60
$params[
'sort'
] =
null
;
61
}
62
63
return
new
Column
($id, $params);
64
}
65
}
Bitrix\Main\Grid\Column\Column
Definition
column.php:13
Bitrix\Main\Grid\Column\Editable\Factory\ConfigFactory
Definition
configfactory.php:15
Bitrix\Main\Grid\Column\Factory\ColumnFactory
Definition
columnfactory.php:10
Bitrix\Main\Grid\Column\Factory\ColumnFactory\__construct
__construct()
Definition
columnfactory.php:13
Bitrix\Main\Grid\Column\Factory\ColumnFactory\createFromArray
createFromArray(array $params)
Definition
columnfactory.php:18
Bitrix\Main\Grid\Column\Type
Definition
type.php:8
Bitrix\Main\Grid\Column\Factory
Definition
columnfactory.php:3
modules
main
lib
grid
column
factory
columnfactory.php
Создано системой
1.10.0