mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
N°4621 Fix naming inconsistencies in sources/*
This commit is contained in:
45
sources/Application/UI/Base/Component/Pill/PillFactory.php
Normal file
45
sources/Application/UI/Base/Component/Pill/PillFactory.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2021 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base\Component\Pill;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\Helper\UIHelper;
|
||||
use MetaModel;
|
||||
|
||||
/**
|
||||
* Class PillFactory
|
||||
*
|
||||
* @internal
|
||||
* @author Eric Espie <eric.espie@combodo.com>
|
||||
* @since 3.0.0
|
||||
* @package Combodo\iTop\Application\UI\Base\Component\Pill
|
||||
*/
|
||||
class PillFactory
|
||||
{
|
||||
/**
|
||||
* @param string $sClass
|
||||
* @param string $sStateCode
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\Pill\Pill
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public static function MakeForState(string $sClass, string $sStateCode)
|
||||
{
|
||||
$oPill = new Pill();
|
||||
|
||||
// First we try to apply style defined in the DM if any, otherwise we fallback on the default colors
|
||||
$oStyle = MetaModel::GetEnumStyle($sClass, MetaModel::GetStateAttributeCode($sClass), $sStateCode);
|
||||
if ($oStyle !== null) {
|
||||
$oPill->SetCSSColorClass($oStyle->GetStyleClass());
|
||||
} else {
|
||||
$oPill->SetSemanticColor(UIHelper::GetColorNameFromStatusCode($sStateCode));
|
||||
}
|
||||
|
||||
return $oPill;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user