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

@@ -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',

View File

@@ -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 ?? []));

View File

@@ -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
{

View File

@@ -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 {