Skip to content

Commit

Permalink
DataSources: MergedDataSource - support class subtypes
Browse files Browse the repository at this point in the history
  • Loading branch information
janpecha committed Dec 5, 2023
1 parent d246c5f commit d5a9bc3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/DataSources/MergedDataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,16 @@ public function getRowId($row)
if (is_array($row)) {
throw new \Inteve\DataGrid\InvalidArgumentException(self::class . ' requires only objects, array given.');
}

$class = get_class($row);

if (!isset($this->dataSources[$class])) {
foreach ($this->dataSources as $dataSourceClass => $dataSource) {
if ($row instanceof $dataSourceClass) {
return $dataSource->getRowId($row);
}
}

throw new \Inteve\DataGrid\InvalidArgumentException('Unknow row type, there is no data source for it.');
}

Expand Down

0 comments on commit d5a9bc3

Please sign in to comment.