mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 15:34:12 +01:00
Internal - Add parameter $aDesiredAttTypes to the MetaModel::GetAttributesList() to filter the result on some attribute types only
This commit is contained in:
@@ -1232,15 +1232,36 @@ abstract class MetaModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of attributes codes for the $sClass. The list can be limited to some attribute types only.
|
||||
*
|
||||
* @param string $sClass
|
||||
* @param string[] $aDesiredAttTypes Array of AttributeDefinition classes to filter the list on
|
||||
*
|
||||
* @return array
|
||||
* @throws \CoreException
|
||||
*/
|
||||
final public static function GetAttributesList($sClass)
|
||||
final public static function GetAttributesList($sClass, $aDesiredAttTypes = [])
|
||||
{
|
||||
self::_check_subclass($sClass);
|
||||
return array_keys(self::$m_aAttribDefs[$sClass]);
|
||||
|
||||
if(empty($aDesiredAttTypes))
|
||||
{
|
||||
return array_keys(self::$m_aAttribDefs[$sClass]);
|
||||
}
|
||||
|
||||
$aMatchingAttCodes = [];
|
||||
foreach(self::$m_aAttribDefs[$sClass] as $sAttCode => $oAttDef)
|
||||
{
|
||||
foreach($aDesiredAttTypes as $sDesiredAttType)
|
||||
{
|
||||
if(is_a($oAttDef, $sDesiredAttType))
|
||||
{
|
||||
$aMatchingAttCodes[] = $sAttCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $aMatchingAttCodes;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user