diff --git a/src/Common/BaseItemList.php b/src/Common/BaseItemList.php index 8320d1c1..310621f4 100644 --- a/src/Common/BaseItemList.php +++ b/src/Common/BaseItemList.php @@ -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]);