[CONFIG] Make it possible to write module configuration in a config.{php,yml,yaml,xml} file and set each value as properties in the module object
This commit is contained in:
@@ -27,18 +27,25 @@ use App\Util\Common;
|
||||
abstract class Module
|
||||
{
|
||||
/**
|
||||
* TODO Handle configuration
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* Load values from the config and set them as properties on each module object
|
||||
*/
|
||||
public function __construct()
|
||||
public function loadConfig()
|
||||
{
|
||||
// Load Module settings
|
||||
foreach (Common::config(static::class) as $aname => $avalue) {
|
||||
$this->{$aname} = $avalue;
|
||||
foreach (Common::config(static::MODULE_TYPE . 's') as $module => $values) {
|
||||
if ($module == $this->name()) {
|
||||
foreach ($values as $property => $value) {
|
||||
$this->{$property} = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function name()
|
||||
{
|
||||
return mb_strtolower(explode('\\', static::class)[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the class to store in the cache
|
||||
*
|
||||
|
Reference in New Issue
Block a user