lots of improvements
This commit is contained in:
@@ -30,18 +30,17 @@ class InitController extends ControllerAbstract
|
||||
// modules - filter by permissions
|
||||
$configuration['modules'] = [];
|
||||
foreach ($this->moduleManager->list() as $module) {
|
||||
if ($module instanceof ModuleBrowserInterface === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if user has permission to view this module
|
||||
// Allow access if user has: {module_handle}, {module_handle}.*, or * permission
|
||||
$handle = $module->handle();
|
||||
if (!$this->hasModuleViewPermission($handle)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$configuration['modules'][$handle] = $module->registerBI();
|
||||
|
||||
$integrations = $module->registerBI();
|
||||
if ($integrations !== null) {
|
||||
$configuration['modules'][$handle] = $integrations;
|
||||
}
|
||||
}
|
||||
|
||||
// tenant
|
||||
|
||||
@@ -252,6 +252,29 @@ class ModuleManager
|
||||
$this->repository->deposit($moduleEntry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Boot all enabled modules (must be called after container is ready).
|
||||
*/
|
||||
public function modulesBoot(): void
|
||||
{
|
||||
// Only load modules that are enabled in the database
|
||||
$modules = $this->list();
|
||||
$this->logger->debug('Booting enabled modules', ['count' => count($modules)]);
|
||||
foreach ($modules as $module) {
|
||||
$handle = $module->handle();
|
||||
try {
|
||||
$module->boot();
|
||||
$this->logger->debug('Module booted', ['handle' => $handle]);
|
||||
} catch (Exception $e) {
|
||||
$this->logger->error('Module boot failed: ' . $handle, [
|
||||
'exception' => $e,
|
||||
'message' => $e->getMessage(),
|
||||
'code' => $e->getCode(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan filesystem for module directories and return module instances
|
||||
*
|
||||
@@ -315,29 +338,6 @@ class ModuleManager
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Boot all enabled modules (must be called after container is ready).
|
||||
*/
|
||||
public function modulesBoot(): void
|
||||
{
|
||||
// Only load modules that are enabled in the database
|
||||
$modules = $this->list();
|
||||
$this->logger->debug('Booting enabled modules', ['count' => count($modules)]);
|
||||
foreach ($modules as $module) {
|
||||
$handle = $module->handle();
|
||||
try {
|
||||
$module->boot();
|
||||
$this->logger->debug('Module booted', ['handle' => $handle]);
|
||||
} catch (Exception $e) {
|
||||
$this->logger->error('Module boot failed: ' . $handle, [
|
||||
'exception' => $e,
|
||||
'message' => $e->getMessage(),
|
||||
'code' => $e->getCode(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function moduleInstance(string $handle, ?string $namespace = null): ?ModuleInstanceInterface
|
||||
{
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace KTXC\Module;
|
||||
|
||||
use JsonSerializable;
|
||||
use KTXC\Module\Store\ModuleEntry;
|
||||
use KTXF\Module\ModuleBrowserInterface;
|
||||
use KTXF\Module\ModuleConsoleInterface;
|
||||
use KTXF\Module\ModuleInstanceInterface;
|
||||
|
||||
/**
|
||||
@@ -97,6 +99,11 @@ class ModuleObject implements JsonSerializable
|
||||
return '0.0.0';
|
||||
}
|
||||
|
||||
public function permissions(): array
|
||||
{
|
||||
return $this->instance?->permissions() ?? [];
|
||||
}
|
||||
|
||||
// ===== Computed properties =====
|
||||
|
||||
public function needsUpgrade(): bool
|
||||
@@ -153,14 +160,20 @@ class ModuleObject implements JsonSerializable
|
||||
$this->instance?->upgrade();
|
||||
}
|
||||
|
||||
public function bootUi(): array | null
|
||||
public function registerBI(): array | null
|
||||
{
|
||||
return $this->instance?->bootUi() ?? null;
|
||||
if ($this->instance instanceof ModuleBrowserInterface) {
|
||||
return $this->instance->registerBI();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function permissions(): array
|
||||
public function registerCI(): array | null
|
||||
{
|
||||
return $this->instance?->permissions() ?? [];
|
||||
if ($this->instance instanceof ModuleConsoleInterface) {
|
||||
return $this->instance->registerCI();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user