Skip to content
Snippets Groups Projects
Commit 8189f4bf authored by davisben's avatar davisben
Browse files

Issue #3472357: Error when Encrypt module is enabled

parent be61670b
No related branches found
No related tags found
1 merge request!14Issue #3472357: Error when Encrypt module is enabled
<?php
/**
* Ensure all AWS profiles have a default encryption profile set.
*/
function aws_post_update_encryption_profile_default() {
/** @var \Drupal\aws\Entity\ProfileInterface[] $profiles */
$profiles = \Drupal::entityTypeManager()
->getStorage('aws_profile')
->loadMultiple();
foreach ($profiles as $profile) {
if (!$profile->getEncryptionProfile()) {
$profile
->setEncryptionProfile('_none')
->save();
}
}
}
......@@ -147,23 +147,24 @@ class ProfileForm extends EntityForm {
'#default_value' => $this->entity->getRegion(),
];
if ($this->encryptionProfileManager) {
$options = ['_none' => $this->t('- None -')];
$encryption_options = ['_none' => $this->t('- None -')];
if ($this->encryptionProfileManager) {
$encryption_profiles = $this->encryptionProfileManager->getAllEncryptionProfiles();
foreach ($encryption_profiles as $id => $profile) {
$options[$id] = $profile->label();
$encryption_options[$id] = $profile->label();
}
$form['encryption_profile'] = [
'#type' => 'select',
'#title' => $this->t('Encryption Profile'),
'#description' => $this->t('The encryption profile to use to encrypt the secret key.'),
'#options' => $options,
'#default_value' => $this->entity->getEncryptionProfile(),
];
}
$form['encryption_profile'] = [
'#type' => 'select',
'#title' => $this->t('Encryption Profile'),
'#description' => $this->t('The encryption profile to use to encrypt the secret key.'),
'#options' => $encryption_options,
'#default_value' => $this->entity->getEncryptionProfile(),
'#access' => $this->encryptionProfileManager,
];
return $form;
}
......
......@@ -245,7 +245,7 @@ class Profile extends ConfigEntityBase implements ProfileInterface {
* {@inheritdoc}
*/
public function getEncryptionProfile() {
return $this->encryption_profile;
return $this->encryption_profile ?? '_none';
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment