diff --git a/app/Config/Aauth.php b/app/Config/Aauth.php index 3ac562f..d7e71e4 100644 --- a/app/Config/Aauth.php +++ b/app/Config/Aauth.php @@ -304,6 +304,19 @@ class Aauth extends BaseConfig public $groupDefault = 'default'; public $groupPublic = 'public'; + /* + |-------------------------------------------------------------------------- + | Modules Variables + |-------------------------------------------------------------------------- + | + | 'modules' + | + | Array of active modules + | (default: []) + | + */ + public $modules = []; + /* |-------------------------------------------------------------------------- | Database Variables diff --git a/app/Libraries/Aauth.php b/app/Libraries/Aauth.php index 6caf827..93e7845 100644 --- a/app/Libraries/Aauth.php +++ b/app/Libraries/Aauth.php @@ -58,6 +58,13 @@ class Aauth */ protected $session; + /** + * Array with modules + * + * @var array + */ + protected $modules = []; + /** * Array to store error messages * @@ -124,6 +131,7 @@ class Aauth $this->configApp = new \Config\App(); $this->config = $config; $this->session = $session; + $this->modules = $this->config->modules; $this->cachePermIds = []; $this->cacheGroupIds = []; @@ -2788,4 +2796,29 @@ class Aauth $this->flashInfos = []; $this->session->remove('infos'); } + + /** + * Provides direct access to method in the builder (if available) + * and the database connection. + * + * @param string $name + * @param array $params + * + * @return Model|null + */ + public function __call($name, array $params) + { + foreach ($this->modules as $module) + { + $module = '\\App\\Libraries\\Aauth\\' . $module; + $moduleClass = new $module; + + if (method_exists($moduleClass, $name)) + { + return $moduleClass->$name(...$params); + } + } + + trigger_error('Call to undefined method ' . __CLASS__ . '::' . $name . '()', E_USER_ERROR); + } }