All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
42 lines
753 B
PHP
42 lines
753 B
PHP
<?php
|
|
|
|
namespace Laravel\Prompts\Concerns;
|
|
|
|
use Closure;
|
|
|
|
trait Events
|
|
{
|
|
/**
|
|
* The registered event listeners.
|
|
*
|
|
* @var array<string, array<int, Closure>>
|
|
*/
|
|
protected array $listeners = [];
|
|
|
|
/**
|
|
* Register an event listener.
|
|
*/
|
|
public function on(string $event, Closure $callback): void
|
|
{
|
|
$this->listeners[$event][] = $callback;
|
|
}
|
|
|
|
/**
|
|
* Emit an event.
|
|
*/
|
|
public function emit(string $event, mixed ...$data): void
|
|
{
|
|
foreach ($this->listeners[$event] ?? [] as $listener) {
|
|
$listener(...$data);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Clean the event listeners.
|
|
*/
|
|
public function clearListeners(): void
|
|
{
|
|
$this->listeners = [];
|
|
}
|
|
}
|