mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 07:12:26 +02:00
Enhance Service locator
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user