Enhance Service locator

This commit is contained in:
Eric Espie
2026-01-27 11:54:05 +01:00
parent 390b5c0bc3
commit bfa7a209d6
43 changed files with 338 additions and 210 deletions

View File

@@ -13,7 +13,6 @@ use Combodo\iTop\Application\UI\Base\UIBlock;
use Combodo\iTop\Application\WebPage\WebPage;
use Combodo\iTop\DesignDocument;
use Combodo\iTop\DesignElement;
use Combodo\iTop\PropertyType\Serializer\XMLNormalizer;
use DesignerForm;
use DesignerHiddenField;
use Dict;

View File

@@ -8,6 +8,7 @@
namespace Combodo\iTop\Application\Dashlet;
use Combodo\iTop\Application\Dashlet\Service\DashletService;
use MetaModel;
use ModelReflectionRuntime;
class DashletFactory
@@ -36,7 +37,9 @@ class DashletFactory
public function CreateDashlet(string $sClass, string $sId): Dashlet
{
if (!DashletService::GetInstance()->IsDashletAvailable($sClass)) {
/** @var DashletService $oDashletService */
$oDashletService = MetaModel::GetService('DashletService');
if (!$oDashletService->IsDashletAvailable($sClass)) {
$sClass = 'DashletUnknown';
//throw new DashletException("Dashlet ".json_encode($sClass)." is not available");
}

View File

@@ -15,23 +15,15 @@ use utils;
class DashletService
{
private static DashletService $oInstance;
private array $aDashlets = [];
protected function __construct()
public function __construct()
{
}
final public static function GetInstance(): DashletService
{
if (!isset(static::$oInstance)) {
static::$oInstance = new DashletService();
}
return static::$oInstance;
}
/**
* @param string $sCategory
*
* @return array
* @throws \Combodo\iTop\Application\Dashlet\DashletException
* @throws \DOMFormatException
@@ -109,7 +101,7 @@ class DashletService
* @throws \Combodo\iTop\Application\Dashlet\DashletException
* @throws \DOMFormatException
*/
public function IsDashletAvailable(string $sClass)
public function IsDashletAvailable(string $sClass): bool
{
$this->InitDashletDefinitions();
@@ -121,6 +113,7 @@ class DashletService
*
* @return array
* @throws \Combodo\iTop\Application\Dashlet\DashletException
* @throws \DOMFormatException
*/
public function GetDashletDefinition(string $sClass): array
{