Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
catalogdashboard.php
1<?php
2
4
18
22abstract class CatalogDashboard
23{
24 public const BUTCH_GROUP = 'catalog_general';
25 public const BUTCH_GROUP_SORT = 160;
26
27 protected array $dashboardViewList = [];
28
30 protected Group $group;
31
32 public function __construct()
33 {
34 foreach (static::getDefaultViewList() as $weight => $view)
35 {
36 $this->addView($view, $weight);
37 }
38
39 $this->bindGroup(static::getDefaultGroup());
40 }
41
42 public function bindGroup(Group $group): void
43 {
44 $this->group = $group;
45 }
46
47 public function getGroup(): Group
48 {
49 return $this->group;
50 }
51
52 abstract protected static function getDefaultGroup(): Group;
53
57 abstract protected static function getDefaultViewList(): array;
58
63 abstract public function getBoardKey(): string;
64
69 abstract public function getAccessBoardId(): int;
70
75 abstract public function getBoardVersion(): string;
76
77 abstract public function getBoardTitle(): ?string;
78
80 {
81 $analyticBoard = new AnalyticBoard($this->getBoardKey());
82 $analyticBoard->setBatchKey($this->group->getGroupKey());
83 $analyticBoard->setGroup(static::BUTCH_GROUP);
84 $analyticBoard->setTitle($this->getBoardTitle());
85
86 return $analyticBoard;
87 }
88
90 {
91 $analyticBoardBatch = new AnalyticBoardBatch();
92 $analyticBoardBatch->setKey($this->group->getGroupKey());
93 $analyticBoardBatch->setGroup(static::BUTCH_GROUP);
94 $analyticBoardBatch->setTitle($this->group->getGroupTitle());
95 $analyticBoardBatch->setOrder(static::BUTCH_GROUP_SORT);
96
97 return $analyticBoardBatch;
98 }
99
100 public function getDashboard(): Dashboard
101 {
102 $board = new Dashboard();
103 $board->setVersion($this->getBoardVersion());
104 $board->setBoardKey($this->getBoardKey());
105 $board->setGId(VisualConstructor\Helper\Util::generateUserUniqueId());
106 $board->setUserId(0);
107
108 $board->addRows($this->getRows());
109
110 return $board;
111 }
112
113 public function getRows(): array
114 {
115 ksort($this->dashboardViewList);
116
117 $rows = [];
118 foreach ($this->dashboardViewList as $weight => $view)
119 {
121 $row->setWeight($weight);
122 $rowWidget = $this->buildWidgetFromView($view);
123 $rowWidget->setWeight($row->getLayoutMap()['elements'][0]['id']);
124 $row->addWidgets($rowWidget);
125 $rows[] = $row;
126 }
127
128 return $rows;
129 }
130
131 protected function buildWidgetFromView(ViewRenderable $view): Widget
132 {
133 $widget = new Widget();
134
135 $widget->setGId(VisualConstructor\Helper\Util::generateUserUniqueId());
136 $widget->setWidgetClass(BaseWidget::getClassName());
137 $widget->setViewKey($view::VIEW_KEY);
138 $widget->setCategoryKey('catalog');
139 $widget->setBoardId($this->getBoardKey());
140 $widget->getWidgetHandler(true)
141 ->updateFormElementValue('label', $view->getLabel());
142 $widget->addConfigurations($widget->getWidgetHandler(true)->getConfigurations());
143
144 $report = new Report();
145 $report->setGId(VisualConstructor\Helper\Util::generateUserUniqueId());
146 $report->setReportClassName(get_class($view->getViewHandler()));
147
148 $report->setWidget($widget);
149 $report->addConfigurations($report->getReportHandler(true)->getConfigurations());
150 $widget->addReports($report);
151
152 return $widget;
153 }
154
161 public function addView(View $view, int $weight): void
162 {
163 $this->dashboardViewList[$weight] = $view;
164 }
165
166 public function setHandler(BaseHandler $handler): void
167 {
168 $this->handler = $handler;
169 }
170
171 public function getHandler(): BaseHandler
172 {
173 return $this->handler;
174 }
175
176 public function getActiveViewList(): array
177 {
179 }
180}
static factoryWithHorizontalCells($cellCount=1)
Definition model.php:876