mirror of
https://github.com/Karaka-Management/oms-Dashboard.git
synced 2026-01-11 17:38:41 +00:00
82 lines
2.3 KiB
PHP
Executable File
82 lines
2.3 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Karaka
|
|
*
|
|
* PHP Version 8.0
|
|
*
|
|
* @package Modules\Dashboard
|
|
* @copyright Dennis Eichhorn
|
|
* @license OMS License 1.0
|
|
* @version 1.0.0
|
|
* @link https://karaka.app
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
namespace Modules\Dashboard\Controller;
|
|
|
|
use Modules\Dashboard\Models\DashboardBoardMapper;
|
|
use Modules\Dashboard\Models\DashboardElementInterface;
|
|
use Modules\Dashboard\Models\NullDashboardBoard;
|
|
use phpOMS\Contract\RenderableInterface;
|
|
use phpOMS\Message\RequestAbstract;
|
|
use phpOMS\Message\ResponseAbstract;
|
|
use phpOMS\Views\View;
|
|
|
|
/**
|
|
* Dashboard class.
|
|
*
|
|
* @package Modules\Dashboard
|
|
* @license OMS License 1.0
|
|
* @link https://karaka.app
|
|
* @since 1.0.0
|
|
* @codeCoverageIgnore
|
|
*/
|
|
final class BackendController extends Controller
|
|
{
|
|
/**
|
|
* Routing end-point for application behaviour.
|
|
*
|
|
* @param RequestAbstract $request Request
|
|
* @param ResponseAbstract $response Response
|
|
* @param mixed $data Generic data
|
|
*
|
|
* @return RenderableInterface
|
|
*
|
|
* @since 1.0.0
|
|
* @codeCoverageIgnore
|
|
*/
|
|
public function viewDashboard(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
|
|
{
|
|
$view = new View($this->app->l11nManager, $request, $response);
|
|
$view->setTemplate('/Modules/Dashboard/Theme/Backend/dashboard');
|
|
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000301001, $request, $response));
|
|
|
|
$board = DashboardBoardMapper::get()
|
|
->with('components')
|
|
->where('account', $request->header->account)
|
|
->execute();
|
|
|
|
if ($board instanceof NullDashboardBoard) {
|
|
$board = DashboardBoardMapper::get()->where('id', 1)->execute();
|
|
}
|
|
|
|
$panels = [];
|
|
$boardComponents = $board->getComponents();
|
|
|
|
foreach ($boardComponents as $component) {
|
|
if (!$this->app->moduleManager->isActive($component->module)) {
|
|
continue;
|
|
}
|
|
|
|
$module = $this->app->moduleManager->get($component->module);
|
|
if ($module instanceof DashboardElementInterface) {
|
|
$panels[] = $module->viewDashboard($request, $response, $data);
|
|
}
|
|
}
|
|
|
|
$view->addData('panels', $panels);
|
|
|
|
return $view;
|
|
}
|
|
}
|