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]);