2018-03-20 09:50:40 +08:00
|
|
|
<?php
|
|
|
|
|
2019-07-16 03:44:31 +08:00
|
|
|
namespace App\Contracts;
|
2018-03-20 09:50:40 +08:00
|
|
|
|
2019-11-20 23:16:01 +08:00
|
|
|
use Illuminate\Contracts\Events\Dispatcher;
|
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
abstract class Listener
|
|
|
|
{
|
2019-11-20 23:16:01 +08:00
|
|
|
public static $callbacks = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets up any callbacks that are defined in the child class
|
|
|
|
*
|
|
|
|
* @param $events
|
|
|
|
*/
|
|
|
|
public function subscribe(Dispatcher $events): void
|
|
|
|
{
|
|
|
|
foreach (static::$callbacks as $klass => $cb) {
|
|
|
|
$events->listen($klass, get_class($this).'@'.$cb);
|
|
|
|
}
|
|
|
|
}
|
2018-03-20 09:50:40 +08:00
|
|
|
}
|