Skip to content

Commit

Permalink
feat: Add new argument to TypeBuilder::slice() so that the 'display…
Browse files Browse the repository at this point in the history
…' property can be specified
  • Loading branch information
gsteel committed Jan 21, 2022
1 parent 4c57e6a commit faf6589
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/TypeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ final class TypeBuilder
self::EMBED,
];

public const SLICE_DISPLAY_LIST = 'list';
public const SLICE_DISPLAY_GRID = 'grid';

private const SLICE_DISPLAY = [
self::SLICE_DISPLAY_GRID,
self::SLICE_DISPLAY_LIST,
];

/** @return array<string, mixed> */
public static function uid(string $label, ?string $placeholder = null): array
{
Expand Down Expand Up @@ -388,13 +396,17 @@ public static function slice(
?string $description = null,
array $nonRepeatFields = [],
array $repeatFields = [],
?string $icon = null
?string $icon = null,
?string $displayFormat = null
): array {
Assert::nullOrInArray($displayFormat, self::SLICE_DISPLAY);

return array_filter([
'type' => self::TYPE_SLICE,
'fieldset' => $label,
'description' => $description,
'icon' => $icon,
'display' => $displayFormat,
'non-repeat' => $nonRepeatFields === [] ? null : $nonRepeatFields,
'repeat' => $repeatFields === [] ? null : $repeatFields,
]);
Expand Down

0 comments on commit faf6589

Please sign in to comment.