From cdf5789d62bf4d25bfc50d77a7292a7212fedccd Mon Sep 17 00:00:00 2001 From: Molkobain Date: Tue, 19 Oct 2021 15:04:37 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B02875=20-=20Add=20$bRootFirst=20param.=20?= =?UTF-8?q?to=20MetaModel::EnumChildClasses()=20to=20be=20iso=20with=20Met?= =?UTF-8?q?aModel::EnumParentClasses()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/metamodel.class.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/core/metamodel.class.php b/core/metamodel.class.php index 0e2e81bb0..c806f11e8 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -4131,19 +4131,26 @@ abstract class MetaModel /** * @param string $sClass * @param int $iOption one of ENUM_CHILD_CLASSES_EXCLUDETOP, ENUM_CHILD_CLASSES_ALL + * @param bool $bRootFirst Only when $iOption NOT set to ENUM_CHILD_CLASSES_EXCLUDETOP. If true, the $sClass will be the first element of the returned array, otherwise it will be the last (legacy behavior) * * @return array * @throws \CoreException + * @since 3.0.0 Added $bRootFirst param. */ - public static function EnumChildClasses($sClass, $iOption = ENUM_CHILD_CLASSES_EXCLUDETOP) + public static function EnumChildClasses($sClass, $iOption = ENUM_CHILD_CLASSES_EXCLUDETOP, $bRootFirst = false) { self::_check_subclass($sClass); $aRes = self::$m_aChildClasses[$sClass]; if ($iOption != ENUM_CHILD_CLASSES_EXCLUDETOP) { - // Add it to the list - $aRes[] = $sClass; + if ($bRootFirst) { + // Root class on top + array_unshift($aRes, $sClass); + } else { + // Root class at the end, legacy behavior + $aRes[] = $sClass; + } } return $aRes;