diff --git a/core/metamodel.class.php b/core/metamodel.class.php index 5f1d0c833..8f9808cc2 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -7477,6 +7477,8 @@ abstract class MetaModel * @param string|null $sFilterInstanceOf [optional] if given, only instance of this string will be returned * * @return array classes=>instance implementing the given interface + * + * @see \Combodo\iTop\Service\InterfaceDiscovery\InterfaceDiscovery::FindItopClasses() to add extensibility to modules */ public static function EnumPlugins($sInterface, $sFilterInstanceOf = null) { diff --git a/sources/Service/Cache/DataModelDependantCache.php b/sources/Service/Cache/DataModelDependantCache.php index 174903cef..7fc98ef05 100644 --- a/sources/Service/Cache/DataModelDependantCache.php +++ b/sources/Service/Cache/DataModelDependantCache.php @@ -161,7 +161,7 @@ class DataModelDependantCache /** * for test purpose * - * @param string $sStorageRootDir + * @param string|null $sStorageRootDir if null the current cache path is used */ public function SetStorageRootDir(?string $sStorageRootDir): void { diff --git a/sources/Service/InterfaceDiscovery/InterfaceDiscovery.php b/sources/Service/InterfaceDiscovery/InterfaceDiscovery.php index 22d13c031..77a5688cd 100644 --- a/sources/Service/InterfaceDiscovery/InterfaceDiscovery.php +++ b/sources/Service/InterfaceDiscovery/InterfaceDiscovery.php @@ -10,6 +10,13 @@ use MetaModel; use ReflectionClass; use utils; +/** + * Enumerate classes implementing given interfaces + * + * @api + * + * @since 3.2.0 + */ class InterfaceDiscovery { private static InterfaceDiscovery $oInstance; @@ -17,8 +24,8 @@ class InterfaceDiscovery private ?array $aForcedClassMap = null; // For testing purposes const CACHE_NONE = 'CACHE_NONE'; - const CACHE_DYNAMIC = 'CACHE_DYNAMIC'; - const CACHE_STATIC = 'CACHE_STATIC'; + const CACHE_DYNAMIC = 'CACHE_DYNAMIC'; // rebuild cache when files changes + const CACHE_STATIC = 'CACHE_STATIC'; // Built once at setup private function __construct() { @@ -38,20 +45,20 @@ class InterfaceDiscovery * Find the ITOP classes implementing a given interface. The returned classes have the following properties: * - They can be instantiated * - They are not aliases + * - Their path relative to iTop does not contain /lib/, /node_modules/, /test/ or /tests/ * * @param string $sInterface Fully qualified interface name - * @param array|null $aAdditionalExcludedPaths Optional list of paths to exclude from the search (partial names allowed, case sensitive, use / as separator) * * @return array of fully qualified class names * @throws \ReflectionException when $sInterface is not an interface + * + * @api + * + * @since 3.2.0 */ - public function FindItopClasses(string $sInterface, ?array $aAdditionalExcludedPaths = null): array + public function FindItopClasses(string $sInterface): array { - if (is_null($aAdditionalExcludedPaths)) { - return $this->FindClasses($sInterface, ['/lib/', '/node_modules/', '/test/', '/tests/']); - } - - $aExcludedPaths = array_merge(['/lib/', '/node_modules/', '/test/', '/tests/'], $aAdditionalExcludedPaths); + $aExcludedPaths = ['/lib/', '/node_modules/', '/test/', '/tests/']; return $this->FindClasses($sInterface, $aExcludedPaths); } diff --git a/tests/php-unit-tests/unitary-tests/sources/Service/InterfaceDiscovery/InterfaceDiscoveryTest.php b/tests/php-unit-tests/unitary-tests/sources/Service/InterfaceDiscovery/InterfaceDiscoveryTest.php index e3c8289a4..6695dc4b3 100644 --- a/tests/php-unit-tests/unitary-tests/sources/Service/InterfaceDiscovery/InterfaceDiscoveryTest.php +++ b/tests/php-unit-tests/unitary-tests/sources/Service/InterfaceDiscovery/InterfaceDiscoveryTest.php @@ -49,19 +49,6 @@ class InterfaceDiscoveryTest extends ItopDataTestCase ); } - public function testShouldExcludeSpecifiedDirectories() - { - - $this->GivenClassMap([ - 'Combodo\iTop\Application\UI\Base\Component\Alert\AlertUIBlockFactory' => APPROOT . '/sources/Application/UI/Base/Component/Alert/AlertUIBlockFactory.php', - 'Combodo\iTop\Application\UI\Base\Component\ButtonGroup\ButtonGroupUIBlockFactory' => APPROOT . '/sources/Application/UI/Base/Component/ButtonGroup/ButtonGroupUIBlockFactory.php', - ]); - - $this->AssertArraysHaveSameItems( - [], - $this->oInterfaceDiscovery->FindItopClasses(iUIBlockFactory::class, ['Component/ButtonGroup', '/Alert/']) - ); - } public function testShouldExcludeAliases() { $this->GivenClassMap([