From 643ec3bc4342878085c1b44f8f3609ed803d02e9 Mon Sep 17 00:00:00 2001 From: "lenaick.moreira" Date: Wed, 27 May 2026 14:58:25 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B09169=20-=20Adapt=20ITSM=20designer=20con?= =?UTF-8?q?nector=20to=20the=20new=20setup=20(WIP)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/extensionsmap.class.inc.php | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/setup/extensionsmap.class.inc.php b/setup/extensionsmap.class.inc.php index d1086477c..c62186620 100644 --- a/setup/extensionsmap.class.inc.php +++ b/setup/extensionsmap.class.inc.php @@ -380,6 +380,42 @@ class iTopExtensionsMap return false; } + /** + * Return the list of extensions found in a given directory (not recursively) + * + * @param string $sSearchDir The directory to scan + * + * @return string[]|bool + */ + public function GetExtensionsFromDir($sSearchDir): array|bool + { + if (!is_readable($sSearchDir)) { + return false; + } + + $aExtensions = []; + $hDir = opendir($sSearchDir); + if ($hDir !== false) { + + // Then scan the other files and subdirectories + while (($sDir = readdir($hDir)) !== false) { + if (($sDir === '.') || ($sDir === '..') || !is_dir($sSearchDir.$sDir)) { + continue; + } + + // First check if there is an extension.xml file in this directory + if (is_readable($sSearchDir.$sDir.'/extension.xml')) { + $oXml = new XMLParameters($sSearchDir.$sDir.'/extension.xml'); + $aExtensions[] = $oXml->Get('extension_code'); + } + } + + closedir($hDir); + } + + return $aExtensions; + } + /** * Check if some extension contains a module with missing dependencies... * If so, populate the aMissingDepenencies array