Skip to content

Commit

Permalink
Fetch item class for each row of the data
Browse files Browse the repository at this point in the history
  • Loading branch information
raviks789 authored and nilmerg committed Sep 24, 2024
1 parent f4a7411 commit 09afc04
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Common/BaseItemList.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,24 @@ protected function init(): void
{
}

/**
* Create a list item for the given data
*
* @param object $data
*
* @return BaseListItem|BaseTableRowItem
*/
protected function createListItem(object $data)
{
$className = $this->getItemClass();

return new $className($data, $this);
}

protected function assemble(): void
{
$itemClass = $this->getItemClass();
foreach ($this->data as $data) {
/** @var BaseListItem|BaseTableRowItem $item */
$item = new $itemClass($data, $this);
$item = $this->createListItem($data);
$this->emit(self::BEFORE_ITEM_ADD, [$item, $data]);
$this->addHtml($item);
$this->emit(self::ON_ITEM_ADD, [$item, $data]);
Expand Down

0 comments on commit 09afc04

Please sign in to comment.