crcms / event
event
1.0.2
2019-10-28 12:33 UTC
Requires
- php: >=7.0.0
- illuminate/support: ^5.3|^6.0
README
Set the scheduler
Example::setDispatcher(new \CrCms\Event\Dispatcher);
Register event
Example::registerEvent('event1',$listener);
Push event listener
Example::pushEvent('event1',$listener);
Listening method
//first
$listener => ExampleListener1::class@listen
//second
$listener => ExampleListener2::class
//third
$listener => function($object) {
...
}
class ExampleListener1
{
public function listen($object)
{
...
}
}
class ExampleListener2
{
public function handle($object)
{
...
}
}
function($object) {
...
}
Event trigger
class Example {
use CrCms\Event\HasEvents;
# Set events
public static function events() : array
{
return ['event1','event2'];
}
public function example()
{
# Trigger event
Example::fireEvent('event1',$listener);
}
}