From b68173933c85c9f273a12c73dee99338e52f35eb Mon Sep 17 00:00:00 2001 From: raviks789 Date: Thu, 19 Sep 2024 16:11:05 +0200 Subject: [PATCH] Fetch item class for each row of the data --- src/Common/BaseItemList.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Common/BaseItemList.php b/src/Common/BaseItemList.php index 8320d1c1..ad945a42 100644 --- a/src/Common/BaseItemList.php +++ b/src/Common/BaseItemList.php @@ -62,12 +62,22 @@ protected function init(): void { } + /** + * Create a list item for the given data + * + * @param object $data + * + * @return BaseListItem|BaseTableRowItem + */ + protected function createListItem(object $data) + { + return new ($this->getItemClass())($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]);