Use static methods instead, looks better

This commit is contained in:
slawkens
2026-02-27 15:25:06 +01:00
parent f975bd2f2a
commit 4ca79a1e85
5 changed files with 48 additions and 36 deletions

View File

@@ -8,22 +8,22 @@ class Groups
{
private static array $groups = [];
public function __construct() {
self::$groups = Cache::remember('groups', 10 * 60, function () {
if (file_exists(config('server_path') . 'config/groups.toml')) {
$groups = new TOML\Groups();
}
else {
$groups = new XML\Groups();
}
public static function get() {
if (count(self::$groups) == 0) {
self::$groups = Cache::remember('groups', 10 * 60, function () {
if (file_exists(config('server_path') . TOML\Groups::FILE)) {
$groups = new TOML\Groups();
}
else {
$groups = new XML\Groups();
}
$groups->load();
$groups->load();
return $groups->getGroups();
});
}
return $groups->getGroups();
});
}
public static function getGroups(): array {
return self::$groups;
}
}