Firing and listening
You can fire or listen to events like this:
<?php
$manager->eventDispatcher()->listen('an-event', function() {
print "hello";
})
$manager->eventDispatcher()->fire('an-event'); // outputs "hello"
By default you will find an $events property in AbstractEvent that will be used later on $booter->addListeners()
Obviously you can overide this behaviour using $event->setEvents() / $manager->eventDispatcher()->setEvents() or extending the class
<?php
...
class AbstractEvent implements EventInterface {
/**
* Event name => Extension method name
*
* This will be used in $booter->addListeners()
* thas will listen to 'install.{extensionName}' and
* 'uninstall.{extensionName}' and will call the extension method
* 'install' or 'uninstall'
*
* @var array
*/
protected $events = [
'install' => 'install',
'uninstall' => 'uninstall',
];
...
Updated less than a minute ago