public function FeaturesDiffForm::submitForm in Features 8.3
Same name and namespace in other branches
- 8.4 modules/features_ui/src/Form/FeaturesDiffForm.php \Drupal\features_ui\Form\FeaturesDiffForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- modules/
features_ui/ src/ Form/ FeaturesDiffForm.php, line 189
Class
- FeaturesDiffForm
- Defines the features differences form.
Namespace
Drupal\features_ui\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->assigner
->assignConfigPackages();
$config = $this->featuresManager
->getConfigCollection();
$items = array_filter($form_state
->getValue('diff'));
if (empty($items)) {
$this
->messenger()
->addWarning($this
->t('No configuration was selected for import.'));
return;
}
foreach ($items as $config_name) {
if (isset($config[$config_name])) {
$item = $config[$config_name];
$type = ConfigurationItem::fromConfigStringToConfigType($item
->getType());
$this->configRevert
->revert($type, $item
->getShortName());
}
else {
$item = $this->featuresManager
->getConfigType($config_name);
$type = ConfigurationItem::fromConfigStringToConfigType($item['type']);
$this->configRevert
->import($type, $item['name_short']);
}
$this
->messenger()
->addStatus($this
->t('Imported @name', [
'@name' => $config_name,
]));
}
}