- 커맨드 종료 시점에 호출 - pre, post 각각이 필요한지는 논의 필요 - 일단 용도에 따라 pre, post 둘중에 하나만 처리 - eventType으로는 full qualified class name 사용 - 꼭 그럴필요는 없지만, 커맨드에 한해서는 이렇게
26 lines
733 B
PHP
26 lines
733 B
PHP
<?php
|
|
|
|
namespace sammo;
|
|
|
|
class StaticEventHandler
|
|
{
|
|
// This is a static class, so we don't want to instantiate it
|
|
public function __construct()
|
|
{
|
|
throw new \Exception('This is a static class');
|
|
}
|
|
|
|
public static function handleEvent(General|GeneralLite $general, null|General|GeneralLite $destGeneral, string $eventType, array $env, array ...$params): void
|
|
{
|
|
$handlersList = GameConst::$staticEventHandlers[$eventType] ?? null;
|
|
if ($handlersList === null) {
|
|
return;
|
|
}
|
|
|
|
foreach ($handlersList as $handlerName) {
|
|
$handler = buildStaticEventClass($handlerName);
|
|
$handler->run($general, $destGeneral, $env, ...$params);
|
|
}
|
|
}
|
|
}
|