mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-02-25 11:19:39 +03:00
Theme System: Split & organised tests, changed module version to string
This commit is contained in:
@@ -9,7 +9,7 @@ class ThemeModule
|
||||
protected string $name;
|
||||
protected string $description;
|
||||
protected string $folderName;
|
||||
protected int $version;
|
||||
protected string $version;
|
||||
|
||||
/**
|
||||
* Create a ThemeModule instance from JSON data.
|
||||
@@ -26,10 +26,14 @@ class ThemeModule
|
||||
throw new ThemeException("Module in folder \"{$folderName}\" is missing a valid 'description' property");
|
||||
}
|
||||
|
||||
if (!isset($data['version']) || !is_int($data['version']) || $data['version'] < 1) {
|
||||
if (!isset($data['version']) || !is_string($data['version'])) {
|
||||
throw new ThemeException("Module in folder \"{$folderName}\" is missing a valid 'version' property");
|
||||
}
|
||||
|
||||
if (!preg_match('/^v?\d+\.\d+\.\d+(-.*)?$/', $data['version'])) {
|
||||
throw new ThemeException("Module in folder \"{$folderName}\" has an invalid 'version' format. Expected semantic version format like '1.0.0' or 'v1.0.0'");
|
||||
}
|
||||
|
||||
$module = new static();
|
||||
$module->name = $data['name'];
|
||||
$module->description = $data['description'];
|
||||
|
||||
Reference in New Issue
Block a user