[MODULES] Add module configuration

This commit is contained in:
Diogo Peralta Cordeiro 2021-08-12 00:24:25 +01:00 committed by Hugo Sales
parent de8a2f579c
commit 508f1f8796
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
2 changed files with 38 additions and 0 deletions

View File

@ -33,6 +33,14 @@ use Symfony\Component\HttpFoundation\Request;
*/ */
abstract class Module 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 * Serialize the class to store in the cache
* *

View File

@ -2,6 +2,36 @@
namespace App\Core\Modules; namespace App\Core\Modules;
use App\Core\Event;
abstract class Plugin extends Module 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;
}
} }