Skip to content

Commit

Permalink
Support custom event firing on all menu items
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhamp committed Nov 20, 2024
1 parent 7c1cca5 commit f857938
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Menu/Items/MenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ abstract class MenuItem implements MenuItemContract

protected bool $isChecked = false;

protected ?string $event = null;

public function enabled(): self
{
$this->isEnabled = true;
Expand Down Expand Up @@ -107,12 +109,20 @@ public function submenu(MenuItemContract ...$items): self
return $this;
}

public function event(string $event): self
{
$this->event = $event;

return $this;
}

public function toArray(): array
{
return array_filter([
'type' => $this->type,
'id' => $this->id,
'label' => $this->label,
'event' => $this->event,
'sublabel' => $this->sublabel,
'toolTip' => $this->toolTip,
'enabled' => $this->isEnabled,
Expand Down

0 comments on commit f857938

Please sign in to comment.