Skip to content
Snippets Groups Projects
Commit 3e734ca4 authored by Shawn Duncan's avatar Shawn Duncan
Browse files

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

Issue #3347425 by FatherShawn, zerbash: Config is not storing key module dependencies on first save.
parent 9c7d7064
No related branches found
No related tags found
No related merge requests found
......@@ -176,11 +176,15 @@ class Oauth2Client extends ConfigEntityBase implements Oauth2ClientInterface {
*/
public function calculateDependencies() {
parent::calculateDependencies();
/** @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);
$credentialProvider = $this->getCredentialProvider();
if (\Drupal::hasService('key.repository') && $credentialProvider === 'key') {
/** @var \Drupal\key\KeyRepositoryInterface $keyRepository */
$keyRepository = \Drupal::service('key.repository');
$storageKey = $this->getCredentialStorageKey();
$keyEntity = $keyRepository->getKey($storageKey);
if (!is_null($keyEntity)) {
$this->addDependency('config', $keyEntity->getConfigDependencyName());
}
}
return $this;
}
......
......@@ -56,36 +56,6 @@ class CredentialProvider {
return isset($this->keyRepository);
}
/**
* Provides the configuration dependency name from the optional provider.
*
* @param string $pluginId
* The Oauth2 Client plugin
*
* @return string|null
* The configuration dependency name if it exists. Otherwise NULL.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
public function getCredentialDependencyName(string $pluginId): ?string {
$dependency = NULL;
if ($this->additionalProviders()) {
$config = $this->entityTypeManager->getStorage('oauth2_client')->load($pluginId);
if ($config instanceof Oauth2Client) {
$credentialProvider = $config->getCredentialProvider();
$storageKey = $config->getCredentialStorageKey();
if ($credentialProvider === 'key') {
$keyEntity = $this->keyRepository->getKey($storageKey);
if ($keyEntity instanceof Key) {
$dependency = $keyEntity->getConfigDependencyName();
}
}
}
}
return $dependency;
}
/**
* Get the provided credentials.
*
......
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