HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/posscale/www/printmanager/vendor/filament/forms/src/Components/Concerns/ListensToEvents.php
<?php

namespace Filament\Forms\Components\Concerns;

use Closure;

trait ListensToEvents
{
    /**
     * @var array<string, array<Closure>>
     */
    protected array $listeners = [];

    public function dispatchEvent(string $event, mixed ...$parameters): static
    {
        foreach ($this->getListeners($event) as $callback) {
            $callback($this, ...$parameters);
        }

        return $this;
    }

    /**
     * @param  array<string, array<Closure>>  $listeners
     */
    public function registerListeners(array $listeners): static
    {
        foreach ($listeners as $event => $callbacks) {
            $this->listeners[$event] = [
                ...$this->getListeners($event),
                ...$callbacks,
            ];
        }

        return $this;
    }

    /**
     * @return array<string | int, array<Closure> | Closure>
     */
    public function getListeners(?string $event = null): array
    {
        $listeners = $this->listeners;

        if ($event) {
            return $listeners[$event] ?? [];
        }

        return $listeners;
    }
}