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