Skip to content

Commit b93b097

Browse files
committed
fix-actions-update-action-group
fix #7515
1 parent 640e870 commit b93b097

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/Config/Actions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function update(string $pageName, string $actionName, callable $callable)
5555

5656
$action = $actionDto->getAsConfigObject();
5757

58-
/** @var Action $action */
58+
/** @var Action|ActionGroup $action */
5959
$action = $callable($action);
6060
$this->dto->setAction($pageName, $action->getAsDto());
6161

src/Dto/ActionGroupDto.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,4 +272,41 @@ public function setHasAnyActionWithIcon(bool $hasAnyActionWithIcon): void
272272
{
273273
$this->hasAnyActionWithIcon = $hasAnyActionWithIcon;
274274
}
275+
276+
public function getAsConfigObject(): ActionGroup
277+
{
278+
$action = ActionGroup::new($this->name, $this->label, $this->icon);
279+
$action->setCssClass($this->cssClass);
280+
$action->addCssClass($this->addedCssClass);
281+
$action->setHtmlAttributes($this->htmlAttributes);
282+
$action->setHtmlAttributes($this->htmlAttributes);
283+
284+
if (null !== $this->templatePath) {
285+
$action->setTemplatePath($this->templatePath);
286+
}
287+
288+
if ($this->isGlobalAction()) {
289+
$action->createAsGlobalActionGroup();
290+
}
291+
292+
if (null !== $this->mainAction) {
293+
$action->addMainAction($this->mainAction->getAsConfigObject());
294+
}
295+
296+
foreach ($this->items as $index => $item) {
297+
if ($item instanceof ActionDto) {
298+
$action->addAction($item->getAsConfigObject());
299+
} elseif ('divider' === ($item['type'] ?? null)) {
300+
$action->addDivider();
301+
} elseif ('header' === ($item['type'] ?? null)) {
302+
$action->addHeader($item['content']);
303+
}
304+
}
305+
306+
if (null !== $this->displayCallable) {
307+
$action->displayIf($this->displayCallable);
308+
}
309+
310+
return $action;
311+
}
275312
}

0 commit comments

Comments
 (0)