improve plugin store

This commit is contained in:
xiaomlove
2025-05-05 18:24:17 +07:00
parent 5b71976624
commit fb88455323
15 changed files with 282 additions and 55 deletions
+14 -1
View File
@@ -27,7 +27,7 @@ abstract class BasePlugin extends BaseRepository
public function checkMainApplicationVersion()
{
$constantName = "static::COMPATIBLE_VERSION";
$constantName = "static::COMPATIBLE_NP_VERSION";
if (defined($constantName) && version_compare(VERSION_NUMBER, constant($constantName), '<')) {
throw new \RuntimeException(sprintf(
"NexusPHP version: %s is too low, this plugin require: %s",
@@ -57,4 +57,17 @@ abstract class BasePlugin extends BaseRepository
{
return Plugin::getById(static::ID);
}
public function getVersion(): string
{
$constantName = "static::VERSION";
return defined($constantName) ? constant($constantName) : '';
}
public function getId(): string
{
$className = str_replace("Repository", "", get_called_class());
$plugin = call_user_func([$className, "make"]);
return $plugin->getId();
}
}