context = $context; } /** * Dispatch the event with the given arguments. * @return array|null */ public static function dispatch() { $event = new static(...func_get_args()); $event->setContext(bff::context()); return bff('events')->dispatch($event); } /** * Dispatch the event with the given arguments if the given truth test passes. * @param bool $boolean * @param mixed ...$arguments * @return mixed|void */ public static function dispatchIf($boolean, ...$arguments) { if ($boolean instanceof Closure) { $boolean = $boolean(); } if ($boolean) { return static::dispatch(...$arguments); } } }