remove MTTExtension::name

This commit is contained in:
maxpozdeev 2022-09-23 12:02:50 +03:00
parent 767c669435
commit 0512a5d1a6
2 changed files with 9 additions and 5 deletions

View file

@ -16,6 +16,10 @@ class ExtSettingsController extends ApiController {
if (!$instance) {
return;
}
$meta = MTTExtension::extMetaInfo($ext);
if (!$meta || !isset($meta['name'])) {
return;
}
$data = $instance->settingsPage();
@ -25,7 +29,7 @@ class ExtSettingsController extends ApiController {
$name = htmlspecialchars($lang->get($nameKey));
}
else {
$name = htmlspecialchars($instance::name);
$name = htmlspecialchars($meta['name']);
}
$escapedExt = htmlspecialchars($ext);
$e = function($s) use($lang) { return htmlspecialchars($lang->get($s)); };

View file

@ -74,7 +74,7 @@ abstract class ApiController
abstract class MTTExtension
{
const bundleId = '';
const name = '';
abstract function init();
public static function extMetaInfo(string $ext): ?array
@ -142,11 +142,11 @@ class MTTExtensionLoader
}
$className = get_class($instance);
if (!defined("$className::bundleId") || !defined("$className::name")) {
throw new Exception("Failed to register extension '$ext': require class constants (bundleId, name)");
if (!defined("$className::bundleId")) {
throw new Exception("Failed to load extension '$ext': missing required class constants (bundleId)");
}
if ($instance::bundleId != $ext) {
throw new Exception("Extension '$ext' bundleId does not conforms to extension dir");
throw new Exception("Failed to load extension '$ext': bundleId does not conforms to extension dir");
}
Lang::instance()->loadExtensionLang($ext);