Skip to content

Commit 6c73782

Browse files
committed
fix dynamic
1 parent 6d7a86e commit 6c73782

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/lib/Twig/Components/OverflowList.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ final class OverflowList
2121
*/
2222
public array $items = [];
2323

24+
/**
25+
* @var array<string>
26+
*/
27+
public array $itemTemplateProps = [];
28+
2429
/**
2530
* @param array<string, mixed> $props
2631
*
@@ -35,19 +40,25 @@ public function validate(array $props): array
3540
->define('items')
3641
->allowedTypes('array')
3742
->default([]);
43+
$resolver
44+
->define('itemTemplateProps')
45+
->allowedTypes('array')
46+
->default([]);
3847

3948
return $resolver->resolve($props) + $props;
4049
}
4150

51+
/**
52+
* @return array<string, string>
53+
*/
4254
#[ExposeInTemplate('item_template_props')]
4355
public function getItemTemplateProps(): array
4456
{
45-
$item_props_names = array_keys($this->items[0]);
46-
$item_props_patterns = array_map(
57+
$itemPropsPatterns = array_map(
4758
fn (string $name): string => '{{ ' . $name . ' }}',
48-
$item_props_names
59+
$this->itemTemplateProps
4960
);
5061

51-
return array_combine($item_props_names, $item_props_patterns) ?? [];
62+
return array_combine($this->itemTemplateProps, $itemPropsPatterns);
5263
}
5364
}

0 commit comments

Comments
 (0)