protected function EncryptionProfileForm::updateEncryptionMethod in Encrypt 8.3
Update the EncryptionMethod plugin.
Parameters
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
1 call to EncryptionProfileForm::updateEncryptionMethod()
- EncryptionProfileForm::buildForm in src/
Form/ EncryptionProfileForm.php - Form constructor.
File
- src/
Form/ EncryptionProfileForm.php, line 267
Class
- EncryptionProfileForm
- Provides the form to add / edit an EncryptionProfile entity.
Namespace
Drupal\encrypt\FormCode
protected function updateEncryptionMethod(FormStateInterface $form_state) {
/* @var $encryption_profile \Drupal\encrypt\Entity\EncryptionProfile */
$encryption_profile = $this->entity;
/* @var $plugin \Drupal\encrypt\EncryptionMethodInterface */
$plugin = $encryption_profile
->getEncryptionMethod();
$encryption_profile
->setEncryptionMethod($plugin);
// If an original profile exists and the plugin ID matches the existing one.
if ($this->originalProfile && $this->originalProfile
->getEncryptionMethod()
->getPluginId() == $plugin
->getPluginId()) {
// Use the configuration from the original profile's plugin.
$configuration = $this->originalProfile
->getEncryptionMethod()
->getConfiguration();
}
else {
// Use the plugin's default configuration.
$configuration = $plugin
->defaultConfiguration();
}
$plugin
->setConfiguration($configuration);
$form_state
->setValue('encryption_method_configuration', []);
$form_state
->getUserInput()['encryption_method_configuration'] = [];
}