mirror of
https://github.com/slawkens/myaac.git
synced 2026-03-16 16:03:31 +01:00
Use static methods instead, looks better
This commit is contained in:
@@ -47,8 +47,7 @@ class OTS_Groups_List implements IteratorAggregate, Countable
|
||||
return;
|
||||
}
|
||||
|
||||
$groups = new Groups();
|
||||
foreach($groups->getGroups() as $id => $info) {
|
||||
foreach(Groups::get() as $id => $info) {
|
||||
$this->groups[$id] = new OTS_Group($info);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,10 @@ class Groups
|
||||
{
|
||||
private static array $groups = [];
|
||||
|
||||
public function __construct() {
|
||||
public static function get() {
|
||||
if (count(self::$groups) == 0) {
|
||||
self::$groups = Cache::remember('groups', 10 * 60, function () {
|
||||
if (file_exists(config('server_path') . 'config/groups.toml')) {
|
||||
if (file_exists(config('server_path') . TOML\Groups::FILE)) {
|
||||
$groups = new TOML\Groups();
|
||||
}
|
||||
else {
|
||||
@@ -23,7 +24,6 @@ class Groups
|
||||
});
|
||||
}
|
||||
|
||||
public static function getGroups(): array {
|
||||
return self::$groups;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,12 @@ use MyAAC\Cache\Cache;
|
||||
|
||||
class Mounts
|
||||
{
|
||||
private static array $mounts = [];
|
||||
|
||||
public static function get()
|
||||
{
|
||||
return Cache::remember('mounts', 10 * 60, function () {
|
||||
if (count(self::$mounts) == 0) {
|
||||
self::$mounts = Cache::remember('mounts', 10 * 60, function () {
|
||||
if (file_exists(config('server_path') . TOML\Mounts::FILE)) {
|
||||
$mounts = new TOML\Mounts();
|
||||
}
|
||||
@@ -21,4 +24,7 @@ class Mounts
|
||||
return $mounts->get();
|
||||
});
|
||||
}
|
||||
|
||||
return self::$mounts;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,13 +6,15 @@ use MyAAC\Cache\Cache;
|
||||
|
||||
class Outfits
|
||||
{
|
||||
private static array $outfits = [];
|
||||
|
||||
public static function get()
|
||||
{
|
||||
return Cache::remember('outfits', 10 * 60, function () {
|
||||
if (file_exists(config('server_path') . 'config/outfits.toml')) {
|
||||
if (count(self::$outfits) == 0) {
|
||||
self::$outfits = Cache::remember('outfits', 10 * 60, function () {
|
||||
if (file_exists(config('server_path') . TOML\Outfits::FILE)) {
|
||||
$outfits = new TOML\Outfits();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$outfits = new XML\Outfits();
|
||||
}
|
||||
|
||||
@@ -21,4 +23,7 @@ class Outfits
|
||||
return $outfits->getOutfits();
|
||||
});
|
||||
}
|
||||
|
||||
return self::$outfits;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,11 @@ class Groups
|
||||
{
|
||||
private array $groups = [];
|
||||
|
||||
const FILE = 'config/groups.toml';
|
||||
|
||||
public function load(): void
|
||||
{
|
||||
$file = config('server_path') . 'config/groups.toml';
|
||||
$file = config('server_path') . self::FILE;
|
||||
|
||||
if(!@file_exists($file)) {
|
||||
error('Error: Cannot load groups.toml. More info in system/logs/error.log file.');
|
||||
|
||||
Reference in New Issue
Block a user