Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
rows.php
1
<?php
2
3
namespace
Bitrix\Main\Grid\Row
;
4
5
use
Bitrix\Main\Grid\GridRequest
;
6
use
Bitrix\Main\Grid\GridResponse
;
7
use
Bitrix\Main\Grid\Row\Action\DataProvider
;
8
use
Bitrix\Main\Grid\Row\Action\Action
;
9
use
Bitrix\Main\Grid\UI\Response\GridResponseFactory
;
10
20
class
Rows
21
{
26
private
array $actions;
27
28
protected
RowAssembler
$rowAssembler
;
29
33
protected
array
$actionsProviders
;
34
39
public
function
__construct
(
RowAssembler
$rowAssembler
,
DataProvider
...
$actionsProviders
)
40
{
41
$this->rowAssembler =
$rowAssembler
;
42
43
$this->actionsProviders = [];
44
foreach
(
$actionsProviders
as $provider)
45
{
46
$this->actionsProviders[] = $provider;
47
}
48
}
49
57
public
function
prepareRows
(iterable $rawRows): array
58
{
59
$result = [];
60
61
foreach
($rawRows as $row)
62
{
63
$result[] = $this->
prepareRow
($row);
64
}
65
66
return
$this->rowAssembler->prepareRows($result);
67
}
68
76
protected
function
prepareRow
(array $rawValue): array
77
{
78
$result = [
79
'data'
=> $rawValue,
80
];
81
82
if
(isset($rawValue[
'ID'
]))
83
{
84
$result[
'id'
] = $rawValue[
'ID'
];
85
}
86
87
if
(!empty($this->actionsProviders))
88
{
89
$result[
'actions'
] = [];
90
91
foreach
($this->actionsProviders as $provider)
92
{
93
$result[
'actions'
] += $provider->prepareControls($rawValue);
94
}
95
}
96
97
return
$result;
98
}
99
103
final
public
function
getActions
(): array
104
{
105
if
(!isset($this->actions))
106
{
107
$this->actions = [];
108
109
foreach
($this->actionsProviders as $provider)
110
{
111
foreach
($provider->prepareActions() as $action)
112
{
113
$this->actions[$action::getId()] ??= $action;
114
}
115
}
116
}
117
118
return
$this->actions;
119
}
120
128
final
protected
function
getActionById
(
string
$id): ?
Action
129
{
130
if
(empty($id))
131
{
132
return
null
;
133
}
134
135
return
$this->
getActions
()[$id] ??
null
;
136
}
137
145
public
function
processRequest
(
GridRequest
$request): ?
GridResponse
146
{
147
$result =
null
;
148
149
if
(!check_bitrix_sessid())
150
{
151
return
null
;
152
}
153
154
$actionId = $request->getRowActionId();
155
if
(isset($actionId))
156
{
157
$action = $this->
getActionById
($actionId);
158
if
($action)
159
{
160
$result = $action->processRequest($request->getHttpRequest());
161
}
162
}
163
164
return
165
isset($result)
166
? (
new
GridResponseFactory
)->createFromResult($result)
167
: null
168
;
169
}
170
}
Bitrix\Main\Grid\Row\Action\DataProvider
Definition
dataprovider.php:9
Bitrix\Main\Grid\Row\RowAssembler
Definition
rowassembler.php:33
Bitrix\Main\Grid\Row\Rows
Definition
rows.php:21
Bitrix\Main\Grid\Row\Rows\processRequest
processRequest(GridRequest $request)
Definition
rows.php:145
Bitrix\Main\Grid\Row\Rows\getActionById
getActionById(string $id)
Definition
rows.php:128
Bitrix\Main\Grid\Row\Rows\prepareRow
prepareRow(array $rawValue)
Definition
rows.php:76
Bitrix\Main\Grid\Row\Rows\__construct
__construct(RowAssembler $rowAssembler, DataProvider ... $actionsProviders)
Definition
rows.php:39
Bitrix\Main\Grid\Row\Rows\$actionsProviders
array $actionsProviders
Definition
rows.php:33
Bitrix\Main\Grid\Row\Rows\prepareRows
prepareRows(iterable $rawRows)
Definition
rows.php:57
Bitrix\Main\Grid\Row\Rows\$rowAssembler
RowAssembler $rowAssembler
Definition
rows.php:28
Bitrix\Main\Grid\Row\Rows\getActions
getActions()
Definition
rows.php:103
Bitrix\Main\Grid\UI\Response\GridResponseFactory
Definition
gridresponsefactory.php:10
Bitrix\Main\Grid\GridRequest
Definition
gridrequest.php:17
Bitrix\Main\Grid\GridResponse
Definition
gridresponse.php:13
Bitrix\Main\Grid\Row\Action\Action
Definition
action.php:12
Bitrix\Main\Grid\Row
modules
main
lib
grid
row
rows.php
Создано системой
1.10.0