EloquentMinimalEventDispatcher
A minimal Illuminate\Contracts\Events\Dispatcher implementation, used only as the fallback EloquentQueryRecorder::attach() installs on a Illuminate\Database\Connection that has no event dispatcher of its own — which is the case for Quiote\Database\Adapter\Eloquent\EloquentDatabase’s connect(), which never calls Capsule::setEventDispatcher().
illuminate/events is not a dependency of this codebase (or of illuminate/database itself), so this exists rather than pulling in the full package for one interface.
Supports exactly what Illuminate\Database\Connection actually calls on a connection-level event dispatcher: listen()/dispatch()/hasListeners() for query, transaction and connection-lifecycle events, and until() as a thin wrapper over dispatch(). The queued-event API (push()/flush()/ forgetPushed()) and subscribe() are not part of that surface and are intentionally unimplemented (no-ops / throwing) — if an application attaches this to anything beyond a single DB connection, that is a sign it needs a real event dispatcher, not this one.
Synopsis
Section titled “Synopsis”final class EloquentMinimalEventDispatcher implements Dispatcher
| Implements | Dispatcher |
| Source | EloquentMinimalEventDispatcher.php |
Methods
Section titled “Methods”| Method | Description |
|---|---|
| [`dispatch(string | object $event, array<int, mixed> $payload = [], bool $halt = false): mixed`](#dispatch) |
flush(string $event): void | Flush a set of pushed events. |
forget(string $event): void | Remove a set of listeners from the dispatcher. |
forgetPushed(): void | Forget all of the queued listeners. |
hasListeners(string $eventName): bool | Determine if a given event has listeners. |
| [`listen(Closure | string |
push(string $event, array<int, mixed> $payload = []): void | Register an event and payload to be fired later. |
| [`subscribe(object | string $subscriber): void`](#subscribe) |
| [`until(string | object $event, array<int, mixed> $payload = []): mixed`](#until) |
dispatch()
Section titled “dispatch()”public function dispatch(string|object $event, array<int, mixed> $payload = [], bool $halt = false): mixed
Dispatch an event and call the listeners.
| Parameter | Type | Description |
|---|---|---|
$event | `string“ | “object` |
$payload | array``<``int``, ``mixed``> | |
$halt | bool |
Returns mixed
flush()
Section titled “flush()”public function flush(string $event): void
Flush a set of pushed events.
| Parameter | Type | Description |
|---|---|---|
$event | string |
forget()
Section titled “forget()”public function forget(string $event): void
Remove a set of listeners from the dispatcher.
| Parameter | Type | Description |
|---|---|---|
$event | string |
forgetPushed()
Section titled “forgetPushed()”public function forgetPushed(): void
Forget all of the queued listeners.
hasListeners()
Section titled “hasListeners()”public function hasListeners(string $eventName): bool
Determine if a given event has listeners.
| Parameter | Type | Description |
|---|---|---|
$eventName | string |
Returns bool
listen()
Section titled “listen()”public function listen(Closure|string|array<int, string> $events, Closure|string|array<int, string>|null $listener = null): void
Register an event listener with the dispatcher.
| Parameter | Type | Description |
|---|---|---|
$events | Closure` | string |
$listener | Closure` | string |
push()
Section titled “push()”public function push(string $event, array<int, mixed> $payload = []): void
Register an event and payload to be fired later.
| Parameter | Type | Description |
|---|---|---|
$event | string | |
$payload | array``<``int``, ``mixed``> |
subscribe()
Section titled “subscribe()”public function subscribe(object|string $subscriber): void
Register an event subscriber with the dispatcher.
| Parameter | Type | Description |
|---|---|---|
$subscriber | `object“ | “string` |
until()
Section titled “until()”public function until(string|object $event, array<int, mixed> $payload = []): mixed
Dispatch an event until the first non-null response is returned.
| Parameter | Type | Description |
|---|---|---|
$event | `string“ | “object` |
$payload | array``<``int``, ``mixed``> |
Returns mixed