Skip to content

Commit f857938

Browse files
committed
Support custom event firing on all menu items
1 parent 7c1cca5 commit f857938

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Menu/Items/MenuItem.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ abstract class MenuItem implements MenuItemContract
3030

3131
protected bool $isChecked = false;
3232

33+
protected ?string $event = null;
34+
3335
public function enabled(): self
3436
{
3537
$this->isEnabled = true;
@@ -107,12 +109,20 @@ public function submenu(MenuItemContract ...$items): self
107109
return $this;
108110
}
109111

112+
public function event(string $event): self
113+
{
114+
$this->event = $event;
115+
116+
return $this;
117+
}
118+
110119
public function toArray(): array
111120
{
112121
return array_filter([
113122
'type' => $this->type,
114123
'id' => $this->id,
115124
'label' => $this->label,
125+
'event' => $this->event,
116126
'sublabel' => $this->sublabel,
117127
'toolTip' => $this->toolTip,
118128
'enabled' => $this->isEnabled,

0 commit comments

Comments
 (0)