mirror of
https://github.com/slawkens/myaac.git
synced 2025-05-01 19:59:21 +02:00
Add Settings Class
This commit is contained in:
parent
cdef0796a7
commit
d89d8cdf8d
44
system/libs/Settings.php
Normal file
44
system/libs/Settings.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* CreateCharacter
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2020 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
|
||||
class Settings implements ArrayAccess
|
||||
{
|
||||
private $container = array();
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
if (is_null($offset)) {
|
||||
$this->container[] = $value;
|
||||
} else {
|
||||
$this->container[$offset] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->container[$offset]);
|
||||
}
|
||||
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
if (!isset($this->container[$offset])) {
|
||||
$file = PLUGINS . $offset . '/settings.php';
|
||||
if(!file_exists($file)) {
|
||||
throw new \RuntimeException('Failed to load settings file for plugin: ' . $offset);
|
||||
}
|
||||
|
||||
$this->container[$offset] = require $file;
|
||||
}
|
||||
|
||||
return $this->container[$offset];
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user