[CORE][Event] Make all events return \EventResult, enforced at container build time
This commit is contained in:
@@ -22,6 +22,7 @@ declare(strict_types = 1);
|
||||
namespace App\Core\Modules;
|
||||
|
||||
use App\Util\Common;
|
||||
use EventResult;
|
||||
|
||||
/**
|
||||
* Base class for all GNU social modules (plugins and components)
|
||||
@@ -64,22 +65,23 @@ abstract class Module
|
||||
|
||||
// ------- Module initialize and cleanup ----------
|
||||
|
||||
private function defer(string $cycle)
|
||||
private function defer(string $cycle): EventResult
|
||||
{
|
||||
$type = ucfirst(static::MODULE_TYPE);
|
||||
if (method_exists($this, $method = "on{$cycle}{$type}")) {
|
||||
$this->{$method}();
|
||||
}
|
||||
return EventResult::next;
|
||||
}
|
||||
|
||||
// Can't use __call or it won't be found by our event function finder
|
||||
public function onInitializeModule()
|
||||
public function onInitializeModule(): EventResult
|
||||
{
|
||||
$this->defer('Initialize');
|
||||
return $this->defer('Initialize');
|
||||
}
|
||||
|
||||
public function onCleanupModule()
|
||||
public function onCleanupModule(): EventResult
|
||||
{
|
||||
$this->defer('Cleanup');
|
||||
return $this->defer('Cleanup');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user