From de59823dddb1706670f1d0ac10232efc2248fb95 Mon Sep 17 00:00:00 2001 From: alistair3149 Date: Fri, 5 Jun 2026 19:15:18 -0400 Subject: [PATCH] Register declaratively and remove the root entry-point class Move the remaining procedural registration out of the root SemanticExternalQueryLookup class into the namespace. The extension function is retained (it must run setup-time PHP for the class_alias calls, which have no declarative equivalent) but relocated to SEQL\Setup::onExtensionFunction, reading seqlgExternalRepositoryEndpoints directly from the populated config global. - Add SEQL\Setup with the class_alias calls (SMWExternalQueryLookup, SMWExternalAskQueryLookup) and the HookRegistry registration. - Point extension.json ExtensionFunctions at SEQL\Setup::onExtensionFunction and drop AutoloadClasses; the class now autoloads via AutoloadNamespaces. - Drop load_composer_autoloader: there is no composer autoload block and no third-party runtime dependency, so there is nothing local to load. - Drop the SEQL_VERSION constant and SemanticExternalQueryLookup::getVersion(); the test bootstrap now reads the version from extension.json. - Delete the root SemanticExternalQueryLookup.php. --- SemanticExternalQueryLookup.php | 44 --------------------------------- extension.json | 6 +---- src/Setup.php | 31 +++++++++++++++++++++++ tests/bootstrap.php | 8 +++--- 4 files changed, 37 insertions(+), 52 deletions(-) delete mode 100644 SemanticExternalQueryLookup.php create mode 100644 src/Setup.php diff --git a/SemanticExternalQueryLookup.php b/SemanticExternalQueryLookup.php deleted file mode 100644 index 323263f..0000000 --- a/SemanticExternalQueryLookup.php +++ /dev/null @@ -1,44 +0,0 @@ - $GLOBALS['seqlgExternalRepositoryEndpoints'] - ]; - - $hookRegistry = new HookRegistry( - $options - ); - - $hookRegistry->register(); - } - - /** - * @since 1.0 - * - * @return string|null - */ - public static function getVersion() { - return SEQL_VERSION; - } - -} diff --git a/extension.json b/extension.json index cf88cc8..1c17760 100644 --- a/extension.json +++ b/extension.json @@ -22,11 +22,8 @@ "AutoloadNamespaces": { "SEQL\\": "src/" }, - "AutoloadClasses": { - "SemanticExternalQueryLookup": "SemanticExternalQueryLookup.php" - }, "ExtensionFunctions": [ - "SemanticExternalQueryLookup::onExtensionFunction" + "SEQL\\Setup::onExtensionFunction" ], "config_prefix": "seqlg", "config": { @@ -51,6 +48,5 @@ "description": "An array defines list of namespaces allowed to execute queries against remote sources. Keep empty to allow every namespace." } }, - "load_composer_autoloader": true, "manifest_version": 2 } diff --git a/src/Setup.php b/src/Setup.php new file mode 100644 index 0000000..2dd4b14 --- /dev/null +++ b/src/Setup.php @@ -0,0 +1,31 @@ + $GLOBALS['seqlgExternalRepositoryEndpoints'] + ]; + + $hookRegistry = new HookRegistry( + $options + ); + + $hookRegistry->register(); + } + +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index efc983d..5a0c94b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -12,11 +12,13 @@ die( 'The SemanticMediaWiki test autoloader is not available' ); } -if ( !class_exists( 'SemanticExternalQueryLookup' ) || ( $version = SemanticExternalQueryLookup::getVersion() ) === null ) { - die( "\nSemantic External Query Lookup is not available, please check your Composer or LocalSettings.\n" ); +if ( !is_readable( $extensionJson = __DIR__ . '/../extension.json' ) ) { + die( 'The SemanticExternalQueryLookup extension.json is not readable' ); } -print sprintf( "\n%-20s%s\n", "Semantic External Query Lookup: ", SEQL_VERSION ); +$extensionInfo = json_decode( file_get_contents( $extensionJson ), true ); + +print sprintf( "\n%-20s%s\n", "Semantic External Query Lookup: ", $extensionInfo['version'] ?? 'UNKNOWN' ); $autoLoader = require $autoloaderClassPath; $autoLoader->addPsr4( 'SEQL\\Tests\\', __DIR__ . '/phpunit/Unit' );