Add Icon selection formBlock

This commit is contained in:
Eric Espie
2026-01-12 11:44:31 +01:00
parent ff11aec7fe
commit b58a64e143
4 changed files with 154 additions and 0 deletions

View File

@@ -7,7 +7,11 @@
namespace Combodo\iTop\PropertyType\ValueType\Leaf;
use Combodo\iTop\DesignElement;
use Combodo\iTop\Forms\Block\Base\ChoiceFormBlock;
use Combodo\iTop\PropertyType\ValueType\Branch\AbstractBranchValueType;
use Combodo\iTop\Service\DependencyInjection\ServiceLocator;
use utils;
/**
* @since 3.3.0
@@ -18,4 +22,26 @@ class ValueTypeIcon extends AbstractLeafValueType
{
return ChoiceFormBlock::class;
}
public function InitFromDomNode(DesignElement $oDomNode, ?AbstractBranchValueType $oParent = null): void
{
parent::InitFromDomNode($oDomNode, $oParent);
// Search icons in iTop and extensions
/** @var \ModelReflection $oModelReflection */
$oModelReflection = ServiceLocator::GetInstance()->get('ModelReflection');
$sChoices = "[\n";
$aIcons = $oModelReflection->GetAvailableIcons();
foreach ($aIcons as $aIcon) {
$sValue = utils::QuoteForPHP($aIcon['label']);
$sCode = utils::QuoteForPHP($aIcon['value']);
$sChoices .= <<<PHP
\t\t\t\t$sCode => $sValue,\n
PHP;
}
$sChoices .= "\t\t\t]";
$this->aFormBlockOptionsForPHP['choices'] = $sChoices;
}
}