Skip to content

Commit

Permalink
[Grid] [Data Objects] make Group optional. (#872)
Browse files Browse the repository at this point in the history
* [Grid] [Column] Update getGroup method to allow null return type and add validation in GridService

* Apply php-cs-fixer changes

---------

Co-authored-by: martineiber <11687066+martineiber@users.noreply.github.com>
  • Loading branch information
martineiber and martineiber authored Mar 6, 2025
1 parent 700af31 commit cd3a8a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Grid/Schema/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function getType(): string
return $this->type;
}

public function getGroup(): string
public function getGroup(): ?string
{
return $this->group;
}
Expand Down
4 changes: 4 additions & 0 deletions src/Grid/Service/GridService.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ public function getColumnKeys(ColumnCollection $columnCollection, bool $withGrou
{
return array_map(
static function (Column $column) use ($withGroup) {
if (!$column->getGroup()) {
throw new InvalidArgumentException('Group must be set when withGroup is true');
}

return $column->getKey() . ($withGroup ? '~' . $column->getGroup() : '');
},
$columnCollection->getColumns()
Expand Down

0 comments on commit cd3a8a1

Please sign in to comment.