first(); if ($active_modules){ $path = json_decode($active_modules->value); foreach ($path->modules as $p){ if ($p === $slug){ return true; } } } return false; } public function setActiveModule(string $module): void { $active_modules = Option::where("key", "active_modules")->first(); $path = json_decode($active_modules->value); if (in_array($module, $path->modules)) { unset($path->modules[array_search($module, $path->modules)]); $path->modules = array_values($path->modules); } else { $path->modules[] = $module; } $active_modules->value = json_encode($path, JSON_UNESCAPED_UNICODE); $active_modules->save(); } public function getModuleDir(string $slug) { $module_paths = Option::where("key", "module_paths")->first(); $dirs = []; if ($module_paths){ $path = json_decode($module_paths->value); foreach ($path->paths as $p){ $dirs[] = getConst($p); } } foreach ($dirs as $dir){ foreach (new DirectoryIterator($dir) as $fileInfo) { if(basename($fileInfo->getPathname()) === $slug) { return $fileInfo->getPathname(); } } } return false; } }