Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
panel.php
1<?php
2
4
12
13class Panel
14{
18 private array $actions;
22 private array $controls;
26 private array $providers;
27
31 public function __construct(DataProvider ...$providers)
32 {
33 $this->providers = [];
34 foreach ($providers as $provider)
35 {
36 $this->providers[] = $provider;
37 }
38 }
39
43 final public function getActions(): array
44 {
45 if (!isset($this->actions))
46 {
47 $this->actions = [];
48
49 foreach ($this->providers as $provider)
50 {
51 foreach ($provider->prepareActions() as $action)
52 {
53 $this->actions[$action::getId()] ??= $action;
54 }
55 }
56 }
57
58 return $this->actions;
59 }
60
61 final protected function getActionById(string $id): ?Action
62 {
63 if (empty($id))
64 {
65 return null;
66 }
67
68 return $this->getActions()[$id] ?? null;
69 }
70
74 public function getControls(): array
75 {
76 if (!isset($this->controls))
77 {
78 $this->controls = [];
79
80 foreach ($this->providers as $extraProvider)
81 {
82 $this->controls += $extraProvider->prepareControls();
83 }
84 }
85
86 return $this->controls;
87 }
88
97 public function processRequest(GridRequest $request, ?Filter $filter): ?GridResponse
98 {
99 $result = null;
100
101 if (!check_bitrix_sessid())
102 {
103 return null;
104 }
105
106 // direct actions
107 $action = $this->getActionById(
108 $request->getPanelActionId() ?? ''
109 );
110 if ($action)
111 {
112 $result = $action->processRequest(
113 $request->getHttpRequest(),
114 $request->isSelectedAllPanelRows(),
115 $filter
116 );
117 }
118 else
119 {
120 // group actions
121 $groupAction = $this->getActionById(GroupAction::getId());
122 if ($groupAction)
123 {
124 $result = $groupAction->processRequest(
125 $request->getHttpRequest(),
126 $request->isSelectedAllPanelGroupRows(),
127 $filter
128 );
129 }
130 }
131
132 return
133 isset($result)
134 ? (new GridResponseFactory)->createFromResult($result)
135 : null
136 ;
137 }
138}
getActionById(string $id)
Definition panel.php:61
__construct(DataProvider ... $providers)
Definition panel.php:31
processRequest(GridRequest $request, ?Filter $filter)
Definition panel.php:97