30 parent::__construct($settings);
32 $this->rights = $rights;
59 array_push($result, ... [
79 $isSection = isset($rawFields[
'ROW_TYPE']) && $rawFields[
'ROW_TYPE'] ===
'S';
82 $items = $this->getSectionItems($rawFields);
86 $items = $this->getElementItems($rawFields);
91 foreach ($items as $item)
93 $config = $item->getControl($rawFields);
108 private function getSectionItems(array $rawFields): array
110 if (empty($rawFields[
'ID']))
114 $sectionId = (int)$rawFields[
'ID'];
118 if ($this->rights->canEditSection($sectionId))
120 $detailUrl = $this->getSectionEditUrl($sectionId);
121 if (isset($detailUrl))
129 $item->setUrl($detailUrl);
134 self::appendIfNotNull(
140 if ($this->rights->canDeleteSection($sectionId))
142 self::appendIfNotNull(
156 private function getElementItems(array $rawFields): array
158 if (empty($rawFields[
'ID']))
162 $elementId = (int)$rawFields[
'ID'];
166 if ($this->rights->canEditElement($elementId))
168 $detailUrl = $this->getElementDetailViewUrl($elementId);
169 if (isset($detailUrl))
177 $item->setUrl($detailUrl);
182 if (isset($rawFields[
'ACTIVE']) && $rawFields[
'ACTIVE'] ===
'Y')
184 self::appendIfNotNull(
191 self::appendIfNotNull(
197 self::appendIfNotNull(
204 $result[] =
new SeparatorAction();
211 $result[] =
new SeparatorAction();
214 if ($this->rights->canAddElement($elementId))
216 $copyUrl = $this->getElementCopyUrl($elementId);
225 $item->setUrl($copyUrl);
232 if ($this->rights->canDeleteElement($elementId))
239 $lastItem = $result[array_key_last($result)];
240 if (($lastItem instanceof SeparatorAction) ===
false)
242 $result[] =
new SeparatorAction();
253 private function getSectionEditUrl(
int $sectionId): ?string
255 $urlBuilder = $this->getUrlBuilder();
256 if (!isset($urlBuilder))
261 return $urlBuilder->getSectionDetailUrl($sectionId);
264 private function getElementDetailViewUrl(
int $elementId): ?string
266 $urlBuilder = $this->getUrlBuilder();
267 if (!isset($urlBuilder))
272 return $urlBuilder->getElementDetailUrl($elementId);
275 private function getElementCopyUrl(
int $elementId): ?string
277 $urlBuilder = $this->getUrlBuilder();
278 if (!isset($urlBuilder))
283 return $urlBuilder->getElementCopyUrl($elementId);
288 private static function appendIfNotNull(array &$items, $item): void
getActionById(string $id)