Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
dataprovider.php
1<?php
2
4
7use Error;
8
9abstract class DataProvider
10{
14 private array $actions;
15 private Settings $settings;
16
20 public function __construct(?Settings $settings = null)
21 {
22 if (isset($settings))
23 {
24 $this->settings = $settings;
25 }
26 }
27
35 final protected function getSettings(): Settings
36 {
37 return $this->settings;
38 }
39
47 final protected function getActionById(string $id): ?Action
48 {
49 if (empty($id))
50 {
51 return null;
52 }
53
54 if (!isset($this->actions))
55 {
56 $this->actions = [];
57
58 foreach ($this->prepareActions() as $action)
59 {
60 $this->actions[$action::getId()] = $action;
61 }
62 }
63
64 return $this->actions[$id] ?? null;
65 }
66
72 abstract public function prepareActions(): array;
73
77 public function prepareControls(): array
78 {
79 $result = [];
80
81 foreach ($this->prepareActions() as $action)
82 {
83 $control = $action->getControl();
84 if (isset($control))
85 {
86 $result[] = $control;
87 }
88 }
89
90 return $result;
91 }
92}