Skip to content

Commit

Permalink
BaseItemList: Emit ON_ITEM_ADD event after adding the list item to …
Browse files Browse the repository at this point in the history
…the list
  • Loading branch information
raviks789 committed Mar 20, 2024
1 parent 68667fe commit b99b3d4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Common/BaseItemList.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ abstract class BaseItemList extends BaseHtmlElement
{
use BaseFilter;

/** @var string Emitted while assembling the list after adding each list item */
public const ON_ITEM_ADD = 'item-added';

/** @var array<string, mixed> */
protected $baseAttributes = [
'class' => ['item-list', 'default-layout'],
Expand Down Expand Up @@ -63,6 +66,8 @@ protected function assemble(): void
/** @var BaseListItem|BaseTableRowItem $item */
$item = new $itemClass($data, $this);
$this->addHtml($item);

$this->emit(self::ON_ITEM_ADD, [$item, $data]);
}

if ($this->isEmpty()) {
Expand Down

0 comments on commit b99b3d4

Please sign in to comment.