The League of Extraordinary Packages

Our Packages:

Presented by The League of Extraordinary Packages

Versions:

Getting Started

Events

Listeners

Generator

Additional Arguments

When emitting events, either string or class based, you can supply additional arguments.

$emitter->addListener('event.name', function ($event, $param) {

});

$emitter->emit('event.name', 'param value');

When using class based listeners, the method signature must comply with the interface. Therefor the parameters must have default values.

use League\Event\AbstractEvent;
use League\Event\AbstractListener;

class DomainListener extends AbstractListener
{
    public function handle(AbstractEvent $event, $param = null)
    {
        // Handle the event
    }
}

$emitter->addListener('event.name', new DomainListener);
$emitter->emit('event.name', 'param value');