Skip to content
Snippets Groups Projects
Commit 06d47ec9 authored by David Basham's avatar David Basham Committed by Shawn Duncan
Browse files

Issue #3347425 by zerbash, FatherShawn: Config is not storing key module dependencies correctly

parent 8f12686f
No related branches found
No related tags found
1 merge request!13Issue #3347425: Config is not storing key module dependencies correctly
......@@ -176,8 +176,11 @@ class Oauth2Client extends ConfigEntityBase implements Oauth2ClientInterface {
*/
public function calculateDependencies() {
parent::calculateDependencies();
if (!empty($this->credential_provider) && !empty($this->credential_storage_key) && $this->credential_provider === 'key') {
$this->addDependency('config', $this->credential_storage_key);
/** @var \Drupal\oauth2_client\Service\CredentialProvider $credentials */
$credentials = \Drupal::service('oauth2_client.service.credentials');
$dependencyName = $credentials->getCredentialDependencyName($this->oauth2_client_plugin_id);
if (!empty($dependencyName)) {
$this->addDependency('config', $dependencyName);
}
return $this;
}
......
......@@ -52,7 +52,23 @@ class CredentialProvider {
* True if the KeyRepository is present.
*/
public function additionalProviders(): bool {
return isset($this->keyRepository) && $this->keyRepository instanceof KeyRepositoryInterface;
return isset($this->keyRepository);
}
public function getCredentialDependencyName(string $pluginId): ?string {
$dependency = NULL;
if ($this->additionalProviders()) {
$config = $this->entityTypeManager->getStorage('oauth2_client')->load($pluginId);
$credentialProvider = $config->getCredentialProvider();
$storageKey = $config->getCredentialStorageKey();
if ($credentialProvider === 'key') {
$keyEntity = $this->keyRepository->getKey($storageKey);
if ($keyEntity instanceof Key) {
$dependency = $keyEntity->getConfigDependencyName();
}
}
}
return $dependency;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment