[CORE][Event] Make all events return \EventResult, enforced at container build time

This commit is contained in:
2022-04-03 21:40:32 +01:00
parent aef1fac536
commit d4b7e990ce
60 changed files with 345 additions and 239 deletions

View File

@@ -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');
}
}