39 lines
		
	
	
		
			918 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			918 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace kernel\services;
 | |
| 
 | |
| use kernel\helpers\Manifest;
 | |
| use kernel\models\Option;
 | |
| 
 | |
| class ModuleService
 | |
| {
 | |
| 
 | |
|     public function getModuleInfo(string $module): false|array|string
 | |
|     {
 | |
|         $info = [];
 | |
|         $info['path'] = $module;
 | |
|         if (file_exists($module . "/manifest.json")){
 | |
|             $manifest = file_get_contents($module . "/manifest.json");
 | |
|             $manifest = Manifest::getWithVars($manifest);
 | |
|             $info = array_merge($info, $manifest);
 | |
|         }
 | |
| 
 | |
|         return $info;
 | |
|     }
 | |
| 
 | |
|     public function isActive(string $slug): bool
 | |
|     {
 | |
|         $active_modules= Option::where("key", "active_modules")->first();
 | |
|         if ($active_modules){
 | |
|             $path = json_decode($active_modules->value);
 | |
|             foreach ($path->modules as $p){
 | |
|                 if ($p === $slug){
 | |
|                     return true;
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         return false;
 | |
|     }
 | |
| 
 | |
| } |