crcms / event
event
Installs: 4 234
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
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);
}
}