Skip to content

Commit

Permalink
Simplify test for configuration functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ddrury committed Feb 20, 2023
1 parent edba22d commit b3ff7c0
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions app/Module/ModuleMapProviderTrait.php
Expand Up @@ -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('<a href="%s">The %s service requires an API key.', e($this->getConfigLink()), $this->title());

Expand Down

0 comments on commit b3ff7c0

Please sign in to comment.