diff --git a/src/Entity/SalesforceAuthConfig.php b/src/Entity/SalesforceAuthConfig.php index e784e68c19e8937c531eea3e7c2011896ae60848..2d96212c5df7eebf111ac7422fd02dd7c9a9ba81 100644 --- a/src/Entity/SalesforceAuthConfig.php +++ b/src/Entity/SalesforceAuthConfig.php @@ -140,11 +140,13 @@ class SalesforceAuthConfig extends ConfigEntityBase implements EntityInterface { * The list of plugins, indexed by ID. */ public function getPluginsAsOptions() { - $options = ['' => t('- Select -')]; foreach ($this->authManager()->getDefinitions() as $id => $definition) { $options[$id] = ($definition['label']); } - return $options; + if (!empty($options)) { + return ['' => t('- Select -')] + $options; + } + return []; } } diff --git a/src/Form/SalesforceAuthForm.php b/src/Form/SalesforceAuthForm.php index 51bf499e5b9fe850500348dfa894c9b2c3d9d40b..b4564c0a60702bdd7dcda50d8dc936bd953fe5f9 100644 --- a/src/Form/SalesforceAuthForm.php +++ b/src/Form/SalesforceAuthForm.php @@ -22,6 +22,11 @@ class SalesforceAuthForm extends EntityForm { */ public function form(array $form, FormStateInterface $form_state) { $auth = $this->entity; + if (empty($auth->getPluginsAsOptions())) { + $this->messenger()->addError('No auth provider plugins found. Please enable an auth provider module, e.g. salesforce_jwt, before adding an auth config.'); + $form['#access'] = FALSE; + return $form; + } $form_state->setBuildInfo($form_state->getBuildInfo() + ['auth_config' => $this->config($auth->getConfigDependencyName())]); $form['label'] = [