创建版本

This commit is contained in:
2021-02-22 12:17:00 +08:00
commit af555f49c3
2332 changed files with 369202 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
<?php namespace App\Support;
use Symfony\Component\EventDispatcher\GenericEvent;
class Hook
{
public static function listen($tag, $class)
{
$object = with(new $class);
$methods = get_class_methods($object);
foreach ($methods as $method) {
app('dispatcher')->addListener($tag.'.'.$method, [$object, $method]);
}
unset($object);
}
public static function fire($tag, $data = [])
{
$event = new GenericEvent();
$event->setArguments($data);
$event = app('dispatcher')->dispatch($event, $tag);
return $event->getArguments();
}
}