HasEvents
trait HasEvents
Properties
protected array | $dispatchesEvents | The event map. | |
protected array | $observables | User exposed observable events. | |
static Dispatcher | $dispatcher | Event dispatcher instance | |
static protected array | $traitInitializers | The array of trait initializers that will be called on each new instance. | |
static protected array | $booted | The array of booted instances. |
Methods
Check if we needs to be booted and if so, do it.
Bootstrap traits.
Boot all of the bootable traits.
Initialize any initializable traits.
Register observers.
Register a single observer.
Get the observable event names.
Set the observable event names.
Add an observable event name.
Remove an observable event name.
Fire the given event.
Fire a custom event for the given event.
Filter the event results.
Remove all of the event listeners.
Get the event dispatcher instance.
Set the event dispatcher instance.
Unset the event dispatcher.
Execute a callback without firing any events.
Details
at line 56
protected void
bootIfNotBooted()
Check if we needs to be booted and if so, do it.
at line 73
static protected void
boot()
Bootstrap traits.
at line 83
static protected void
bootTraits()
Boot all of the bootable traits.
at line 108
protected void
initializeTraits()
Initialize any initializable traits.
at line 123
static void
observe(object|array|string $classes)
Register observers.
at line 140
protected void
registerObserver(object|string $class)
Register a single observer.
at line 180
array
getObservableEvents()
Get the observable event names.
at line 197
$this
setObservableEvents(array $observables)
Set the observable event names.
at line 210
void
addObservableEvents(array|mixed $observables)
Add an observable event name.
at line 224
void
removeObservableEvents(array|mixed $observables)
Remove an observable event name.
at line 239
static protected void
registerEvent(string $event, Closure|string $callback)
Register a event with the dispatcher.
at line 255
protected mixed
fireEvent(string $event, bool $halt = true)
Fire the given event.
at line 287
protected mixed|null
fireCustomEvent(string $event, string $method)
Fire a custom event for the given event.
at line 306
protected mixed
filterEventResults(mixed $result)
Filter the event results.
at line 322
static void
flushEventListeners()
Remove all of the event listeners.
at line 344
static Dispatcher
getEventDispatcher()
Get the event dispatcher instance.
at line 355
static void
setEventDispatcher(Dispatcher $dispatcher)
Set the event dispatcher instance.
at line 365
static void
unsetEventDispatcher()
Unset the event dispatcher.
at line 376
static mixed
withoutEvents(callable $callback)
Execute a callback without firing any events.