Skip to content

Commit e11170a

Browse files
committed
NameFomatter should be used for all categories.
1 parent a0c0f08 commit e11170a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/SelectboxTree.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,19 @@ public function process(array $data): array
3434
$categories = [];
3535
foreach ($data as $item) {
3636
if ($item instanceof SelectboxItem) {
37-
$categories[] = $item;
37+
$categoryItem = $item;
3838
} else {
39-
$categories[] = [
39+
$categoryItem = [
4040
'id' => $item['id'],
41-
'name' => $this->nameFormatter === null ? (string) $item['name'] : $this->nameFormatter->format($item['name']),
41+
'name' => (string) $item['name'],
4242
'parent' => $item['parent_id'],
4343
];
4444
}
45+
if ($this->nameFormatter !== null) {
46+
$categoryItem['name'] = $this->nameFormatter->format($categoryItem['name']);
47+
}
48+
49+
$categories[] = $categoryItem;
4550
}
4651

4752
$return = [];

0 commit comments

Comments
 (0)