44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace KTXC\Controllers;
|
|
|
|
use KTXC\Http\Response\JsonResponse;
|
|
use KTXC\Module\ModuleManager;
|
|
use KTXF\Controller\ControllerAbstract;
|
|
use KTXC\SessionTenant;
|
|
use KTXF\Routing\Attributes\AuthenticatedRoute;
|
|
|
|
class InitController extends ControllerAbstract
|
|
{
|
|
public function __construct(
|
|
private readonly SessionTenant $tenant,
|
|
private readonly ModuleManager $moduleManager,
|
|
) {}
|
|
|
|
#[AuthenticatedRoute('/init', name: 'init', methods: ['GET'])]
|
|
public function index(): JsonResponse {
|
|
|
|
$configuration = [];
|
|
|
|
// modules
|
|
$configuration['modules'] = [];
|
|
foreach ($this->moduleManager->list() as $module) {
|
|
if (!method_exists($module, 'bootUi')) {
|
|
continue;
|
|
}
|
|
$configuration['modules'][$module->handle()] = $module->bootUi();
|
|
}
|
|
|
|
// tenant
|
|
$configuration['tenant'] = [
|
|
'id' => $this->tenant->identifier(),
|
|
'domain' => $this->tenant->domain(),
|
|
'label' => $this->tenant->label(),
|
|
];
|
|
|
|
return new JsonResponse($configuration);
|
|
|
|
}
|
|
|
|
}
|