Skip to content

Commit 09afc04

Browse files
raviks789nilmerg
authored andcommitted
Fetch item class for each row of the data
1 parent f4a7411 commit 09afc04

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/Common/BaseItemList.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,24 @@ protected function init(): void
6262
{
6363
}
6464

65+
/**
66+
* Create a list item for the given data
67+
*
68+
* @param object $data
69+
*
70+
* @return BaseListItem|BaseTableRowItem
71+
*/
72+
protected function createListItem(object $data)
73+
{
74+
$className = $this->getItemClass();
75+
76+
return new $className($data, $this);
77+
}
78+
6579
protected function assemble(): void
6680
{
67-
$itemClass = $this->getItemClass();
6881
foreach ($this->data as $data) {
69-
/** @var BaseListItem|BaseTableRowItem $item */
70-
$item = new $itemClass($data, $this);
82+
$item = $this->createListItem($data);
7183
$this->emit(self::BEFORE_ITEM_ADD, [$item, $data]);
7284
$this->addHtml($item);
7385
$this->emit(self::ON_ITEM_ADD, [$item, $data]);

0 commit comments

Comments
 (0)