diff --git a/src/Core/Modules/Module.php b/src/Core/Modules/Module.php index 740d0e45d8..5e6a2c600c 100644 --- a/src/Core/Modules/Module.php +++ b/src/Core/Modules/Module.php @@ -33,6 +33,14 @@ use Symfony\Component\HttpFoundation\Request; */ abstract class Module { + public function __construct() + { + // Load Module settings + foreach (Common::config(static::class) as $aname => $avalue) { + $this->{$aname} = $avalue; + } + } + /** * Serialize the class to store in the cache * diff --git a/src/Core/Modules/Plugin.php b/src/Core/Modules/Plugin.php index 70b005242e..1db0702780 100644 --- a/src/Core/Modules/Plugin.php +++ b/src/Core/Modules/Plugin.php @@ -2,6 +2,36 @@ namespace App\Core\Modules; +use App\Core\Event; + abstract class Plugin extends Module { + public function __construct() + { + parent::__construct(); + } + + public function name() + { + $cls = get_class($this); + return mb_substr($cls, 0, -6); + } + + public function version() + { + return GNUSOCIAL_BASE_VERSION; + } + + public function onPluginVersion(array &$versions): bool + { + $name = $this->name(); + + $versions[] = [ + 'name' => $name, + // TRANS: Displayed as version information for a plugin if no version information was found. + 'version' => _m('Unknown'), + ]; + + return Event::next; + } } \ No newline at end of file