Files
iTop/sources/Application/UI/Base/Layout/DashletPanel/DashletPanelFactory.php
2026-01-27 11:54:05 +01:00

40 lines
1.3 KiB
PHP

<?php
namespace Combodo\iTop\Application\UI\Base\Layout\DashletPanel;
use Combodo\iTop\Application\Dashlet\Service\DashletService;
use MetaModel;
class DashletPanelFactory
{
public static function MakeForDashboardEditor(string $sId = null): DashletPanel
{
/** @var DashletService $oDashletService */
$oDashletService = MetaModel::GetService('DashletService');
$oDashletPanel = new DashletPanel($sId);
$aAvailableDashlets = $oDashletService->GetAvailableDashlets('can_be_created');
foreach ($aAvailableDashlets as $sDashletClass => $aDashletInformation) {
$oDashletEntry = new DashletEntry($sDashletClass, $aDashletInformation['label'], $aDashletInformation['description'], $aDashletInformation['icon']);
if (isset($aDashletInformation['min_width'])) {
$oDashletEntry->SetDashletMinWidth($aDashletInformation['min_width']);
}
if (isset($aDashletInformation['min_height'])) {
$oDashletEntry->SetDashletMinHeight($aDashletInformation['min_height']);
}
if (isset($aDashletInformation['preferred_width'])) {
$oDashletEntry->SetDashletPreferredWidth($aDashletInformation['preferred_width']);
}
if (isset($aDashletInformation['preferred_height'])) {
$oDashletEntry->SetDashletPreferredHeight($aDashletInformation['preferred_height']);
}
$oDashletPanel->AddDashletEntry($oDashletEntry);
}
return $oDashletPanel;
}
}