Skip to content
This repository was archived by the owner on Apr 12, 2022. It is now read-only.

Commit 4a3bf1f

Browse files
authored
Endpoint: FIx compatibility with SelectboxTree.
1 parent 3961a41 commit 4a3bf1f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/Api/StaticPageEndpoint.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Baraja\Doctrine\EntityManager;
99
use Baraja\Localization\Translation;
10+
use Baraja\SelectboxTree\SelectboxItem;
1011
use Baraja\SelectboxTree\SelectboxTree;
1112
use Baraja\StaticPage\Entity\StaticPage;
1213
use Baraja\StructuredApi\BaseEndpoint;
@@ -209,13 +210,16 @@ public function actionStaticPagesAsTree(): void
209210
$data = [];
210211
}
211212

212-
$this->sendJson($this->formatBootstrapSelectArray($tree->process(array_map(static function (array $item) {
213-
$item['name'] = $item['title'];
213+
$items = [];
214+
foreach ($data as $item) {
215+
$items[] = new SelectboxItem(
216+
(int) $item['id'],
217+
(string) new Translation($item['title']),
218+
$item['parent_id'] ? (int) $item['parent_id'] : null
219+
);
220+
}
214221

215-
return $item;
216-
}, $data), static function ($name): string {
217-
return (string) new Translation($name);
218-
})));
222+
$this->sendJson($this->formatBootstrapSelectArray($tree->process($items)));
219223
}
220224

221225

0 commit comments

Comments
 (0)