Files
Leantime/app/Core/Events/Concerns/InteractsWithEvents.php
wangruiguo d647428529
Some checks failed
Security Audit / Composer Security Audit (push) Has been cancelled
Security Audit / NPM Security Audit (push) Has been cancelled
Security Audit / CodeQL Analysis (push) Has been cancelled
OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)
2026-09-03 18:49:20 +08:00

43 lines
1.3 KiB
PHP

<?php
namespace Leantime\Core\Events\Concerns;
use Leantime\Core\Events\EventDispatcher;
/**
* Shared behavior for class-based domain events.
*
* Provides the static dispatch() ergonomic and a default empty legacyHooks() so events
* introduced after the class-based system don't need to declare one:
*
* TicketUpdated::dispatch(ticketId: $id);
*
* Do NOT combine with Laravel's Dispatchable trait — both define dispatch(), and the
* Dispatchable version routes through the generic object path instead of the
* LeantimeEvent fast path.
*/
trait InteractsWithEvents
{
/**
* Default: no legacy string names. Override during the migration window with the
* exact historical leantime.* name of the CURRENT emit site — rebuilt from a
* `legacyHook: __FUNCTION__` constructor discriminator when several methods
* historically fired the same raw hook (see the LeantimeEvent docblock).
*
* @return array<int, string>
*/
public function legacyHooks(): array
{
return [];
}
/**
* Construct and dispatch this event through the Leantime event dispatcher.
* Arguments (named arguments included) are forwarded to the constructor.
*/
public static function dispatch(mixed ...$args): void
{
EventDispatcher::dispatch_event(new static(...$args));
}
}