From b3ff7c02f57c6564a6cb1505f71dcbbbc835deff Mon Sep 17 00:00:00 2001 From: David Drury Date: Mon, 20 Feb 2023 20:17:49 +0000 Subject: [PATCH] Simplify test for configuration functions --- app/Module/ModuleMapProviderTrait.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/Module/ModuleMapProviderTrait.php b/app/Module/ModuleMapProviderTrait.php index e6aa7d16cfc..c28f89d41fd 100644 --- a/app/Module/ModuleMapProviderTrait.php +++ b/app/Module/ModuleMapProviderTrait.php @@ -43,19 +43,15 @@ public function leafletJsTileLayers(): array } /** - * If module requires an api key then return false if not valid + * Check if Module contains the functions for a config page, + * If so then an api key is required so check if it is empty * * @return bool * @throws HttpServerErrorException */ public function hasApiKey(): bool { - $api_key = $this->getPreference('api_key'); - - // Do the functions to manage the config page exist in the provider module? - $function_diff = array_diff(get_class_methods(get_class($this)), get_class_methods((string) get_parent_class($this))); - - $error = in_array("getAdminAction", $function_diff) && $api_key === ''; + $error = in_array("getAdminAction", get_class_methods($this)) && $this->getPreference('api_key') === ''; if ($error && Auth::isAdmin()) { $message = I18N::translate('The %s service requires an API key.', e($this->getConfigLink()), $this->title());