Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
groupaction.php
1<?php
2
4
12
13abstract class GroupAction implements Action
14{
18 private array $items;
19
25 final public static function getId(): string
26 {
27 return 'group_action';
28 }
29
33 abstract protected function prepareChildItems(): array;
34
40 private function getChildItems(): array
41 {
42 $this->items ??= $this->prepareChildItems();
43
44 return $this->items;
45 }
46
50 public function getControl(): ?array
51 {
52 $items = $this->getGroupDropdownItems();
53 if (empty($items))
54 {
55 return null;
56 }
57
58 return [
59 'TYPE' => Types::DROPDOWN,
60 'ID' => static::getId(),
61 'NAME' => static::getId(),
62 'ITEMS' => [
63 [
64 'NAME' => Loc::getMessage('MAIN_GRID_PANEL_GROUP_ACTIONS_ITEM_PLACEHOLDER'),
65 'VALUE' => 'default',
66 'ONCHANGE' => [
67 [
68 'ACTION' => Actions::RESET_CONTROLS,
69 ],
70 ],
71 ],
72 ... $items,
73 ],
74 ];
75 }
76
82 private function getGroupDropdownItems(): array
83 {
84 $result = [];
85
86 foreach ($this->getChildItems() as $item)
87 {
88 $result[] = $item->getDropdownItem();
89 }
90
91 return $result;
92 }
93
97 final public function processRequest(HttpRequest $request, bool $isSelectedAllRows, ?Filter $filter): ?Result
98 {
99 $controls = $request->getPost('controls');
100 $itemId = (string)($controls[static::getId()] ?? '');
101 if (empty($itemId))
102 {
103 return null;
104 }
105
106 foreach ($this->getChildItems() as $item)
107 {
108 if ($item::getId() === $itemId)
109 {
110 return $item->processRequest($request, $isSelectedAllRows, $filter);
111 }
112 }
113
114 return null;
115 }
116}
processRequest(HttpRequest $request, bool $isSelectedAllRows, ?Filter $filter)
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29