protected function KeyFormBase::updateKeyType in Key 8
Update the Key Type plugin.
1 call to KeyFormBase::updateKeyType()
- KeyFormBase::buildForm in src/
Form/ KeyFormBase.php - Form constructor.
File
- src/
Form/ KeyFormBase.php, line 354
Class
- KeyFormBase
- Base form for key add and edit forms.
Namespace
Drupal\key\FormCode
protected function updateKeyType(FormStateInterface $form_state) {
/* @var $key \Drupal\key\Entity\Key */
$key = $this->entity;
/* @var $plugin \Drupal\key\Plugin\KeyPluginInterface */
$plugin = $key
->getKeyType();
$key
->setPlugin('key_type', $plugin
->getPluginId());
// If an original key exists and the plugin ID matches the existing one.
if ($this->originalKey && $this->originalKey
->getKeyType()
->getPluginId() == $plugin
->getPluginId()) {
// Use the configuration from the original key's plugin.
$configuration = $this->originalKey
->getKeyType()
->getConfiguration();
}
else {
// Use the plugin's default configuration.
$configuration = $plugin
->defaultConfiguration();
}
$plugin
->setConfiguration($configuration);
$form_state
->setValue('key_type_settings', []);
$form_state
->getUserInput()['key_type_settings'] = [];
}