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:
@@ -15,8 +15,8 @@ use Combodo\iTop\Forms\IO\Format\ClassIOFormat;
|
||||
use Combodo\iTop\Forms\Register\IORegister;
|
||||
use Combodo\iTop\Forms\Register\OptionsRegister;
|
||||
use Combodo\iTop\Forms\Register\RegisterException;
|
||||
use Combodo\iTop\Service\DependencyInjection\DIException;
|
||||
use Combodo\iTop\Service\DependencyInjection\ServiceLocator;
|
||||
use Combodo\iTop\Service\ServiceLocator\ServiceLocatorException;
|
||||
use Combodo\iTop\Service\ServiceLocator\ServiceLocator;
|
||||
use utils;
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ class AttributeChoiceFormBlock extends ChoiceFormBlock
|
||||
/**
|
||||
* @inheritdoc
|
||||
*
|
||||
* @throws DIException
|
||||
* @throws ServiceLocationException
|
||||
* @throws FormBlockException
|
||||
* @throws RegisterException
|
||||
*/
|
||||
@@ -89,11 +89,12 @@ class AttributeChoiceFormBlock extends ChoiceFormBlock
|
||||
* @param string|null $sCategory
|
||||
*
|
||||
* @return array
|
||||
* @throws \Combodo\iTop\Service\DependencyInjection\DIException
|
||||
* @throws \Combodo\iTop\Service\ServiceLocator\ServiceLocatorException
|
||||
*/
|
||||
public static function ListAttributeCodesByCategory(string $sClass, string $sCategory = ''): array
|
||||
{
|
||||
$oModelReflection = ServiceLocator::GetInstance()->get('ModelReflection');
|
||||
/** @var \ModelReflection $oModelReflection */
|
||||
$oModelReflection = \MetaModel::GetService('ModelReflection');
|
||||
$aNonGroupableAttributes = [
|
||||
'AttributeLinkedSet',
|
||||
'AttributeFriendlyName',
|
||||
|
||||
@@ -13,7 +13,7 @@ use Combodo\iTop\Forms\IO\Format\AttributeIOFormat;
|
||||
use Combodo\iTop\Forms\IO\Format\ClassIOFormat;
|
||||
use Combodo\iTop\Forms\Register\IORegister;
|
||||
use Combodo\iTop\Forms\Register\OptionsRegister;
|
||||
use Combodo\iTop\Service\DependencyInjection\ServiceLocator;
|
||||
use Combodo\iTop\Service\ServiceLocator\ServiceLocator;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ class AttributeValueChoiceFormBlock extends ChoiceFormBlock
|
||||
|
||||
try {
|
||||
/** @var \ModelReflection $oModelReflection */
|
||||
$oModelReflection = ServiceLocator::GetInstance()->get('ModelReflection');
|
||||
$oModelReflection = \MetaModel::GetService('ModelReflection');
|
||||
$aValues = $oModelReflection->GetAllowedValues_att($sClass, $sAttCode);
|
||||
|
||||
$oOptionsRegister->SetOption('choices', array_flip($aValues ?? []));
|
||||
|
||||
@@ -36,7 +36,6 @@ class AggregateFunctionFormBlock extends ChoiceFormBlock
|
||||
*
|
||||
* @throws \Combodo\iTop\Forms\Block\FormBlockException
|
||||
* @throws \Combodo\iTop\Forms\Register\RegisterException
|
||||
* @throws \Combodo\iTop\Service\DependencyInjection\DIException
|
||||
*/
|
||||
public function UpdateOptions(OptionsRegister $oOptionsRegister): void
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Combodo\iTop\Forms\Block\DataModel\Dashlet;
|
||||
use Combodo\iTop\Forms\Block\DataModel\AttributeChoiceFormBlock;
|
||||
use Combodo\iTop\Forms\Block\FormBlockException;
|
||||
use Combodo\iTop\Forms\Register\OptionsRegister;
|
||||
use Combodo\iTop\Service\DependencyInjection\ServiceLocator;
|
||||
use Combodo\iTop\Service\ServiceLocator\ServiceLocator;
|
||||
use Dict;
|
||||
use Exception;
|
||||
|
||||
@@ -27,12 +27,13 @@ class ClassAttributeGroupByFormBlock extends AttributeChoiceFormBlock
|
||||
*
|
||||
* @throws \Combodo\iTop\Forms\Block\FormBlockException
|
||||
* @throws \Combodo\iTop\Forms\Register\RegisterException
|
||||
* @throws \Combodo\iTop\Service\DependencyInjection\DIException
|
||||
* @throws \Combodo\iTop\Service\ServiceLocator\ServiceLocatorException
|
||||
*/
|
||||
public function UpdateOptions(OptionsRegister $oOptionsRegister): void
|
||||
{
|
||||
parent::UpdateOptions($oOptionsRegister);
|
||||
$oModelReflection = ServiceLocator::GetInstance()->get('ModelReflection');
|
||||
/** @var \ModelReflection $oModelReflection */
|
||||
$oModelReflection = \MetaModel::GetService('ModelReflection');
|
||||
|
||||
$aGroupBy = [];
|
||||
try {
|
||||
|
||||
@@ -11,27 +11,18 @@ use Combodo\iTop\Forms\Block\Base\FormBlock;
|
||||
use Combodo\iTop\PropertyType\Compiler\PropertyTypeCompiler;
|
||||
use Combodo\iTop\PropertyType\PropertyTypeService;
|
||||
use Combodo\iTop\Service\Cache\DataModelDependantCache;
|
||||
use Combodo\iTop\Service\DependencyInjection\ServiceLocator;
|
||||
use Combodo\iTop\Service\ServiceLocator\ServiceLocator;
|
||||
use ModelReflection;
|
||||
use ModelReflectionRuntime;
|
||||
use utils;
|
||||
|
||||
class FormBlockService
|
||||
{
|
||||
private static FormBlockService $oInstance;
|
||||
private PropertyTypeService $oPropertyTypeService;
|
||||
|
||||
protected function __construct(ModelReflection $oModelReflection = null)
|
||||
public function __construct(ModelReflection $oModelReflection = null)
|
||||
{
|
||||
ServiceLocator::GetInstance()->RegisterService('ModelReflection', $oModelReflection ?? new ModelReflectionRuntime());
|
||||
}
|
||||
|
||||
final public static function GetInstance(ModelReflection $oModelReflection = null): FormBlockService
|
||||
{
|
||||
if (!isset(static::$oInstance)) {
|
||||
static::$oInstance = new FormBlockService($oModelReflection);
|
||||
}
|
||||
|
||||
return static::$oInstance;
|
||||
$this->oPropertyTypeService = \MetaModel::GetService('PropertyTypeService');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,7 +37,7 @@ class FormBlockService
|
||||
*/
|
||||
public function GetFormBlockById(string $sId, string $sType): FormBlock
|
||||
{
|
||||
return PropertyTypeService::GetInstance()->GetFormBlockById($sId, $sType);
|
||||
return $this->oPropertyTypeService->GetFormBlockById($sId, $sType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user