Events
See trigger()
, dispatcher()
.
Dispatcher
Global Dispatcher
is automatically registered.
Events
You can trigger events by calling trigger()
function (or dispatcher()->trigger()
), pass the required event name and optional event parameters.
trigger('my-event', ['foo' => true, 'bar' => false]);
Handlers
Handlers only need to implement the handle()
method. Parameters are injected into constructor and matched by type and name.
<?php
namespace Vendor\Domain\Handler;
class MyHandler
{
public function __construct(protected bool $foo, protected bool $bar) {}
public function handle()
{
console.log('Handling ' . static::class);
}
}
Last updated
Was this helpful?