public function ModuleMissingMessageFixerForm::submitForm in Module Missing Message Fixer 8
Same name and namespace in other branches
- 2.0.x src/Form/ModuleMissingMessageFixerForm.php \Drupal\module_missing_message_fixer\Form\ModuleMissingMessageFixerForm::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
- src/
Form/ ModuleMissingMessageFixerForm.php, line 122
Class
- ModuleMissingMessageFixerForm
- Class ModuleMissingMessageFixerForm.
Namespace
Drupal\module_missing_message_fixer\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$modules = [];
// Go through each record and add it to the array to win.
foreach ($form_state
->getValue([
'table',
]) as $module) {
if ($module) {
$modules[] = $module;
// Clean up old migrate configuration.
$like = $this->connection
->escapeLike($module . '.');
$config_names = $this->connection
->select('config', 'c')
->fields('c', [
'name',
])
->condition('name', $like . '%', 'LIKE')
->execute()
->fetchAll();
// Delete each config using configFactory.
foreach ($config_names as $config_name) {
$this->configFactory
->getEditable($config_name->name)
->delete();
}
// Reminds users to export config.
if (!empty($config_name)) {
$this->messenger
->addWarning("Don't forget to export your config");
}
}
}
// Delete if there is no modules.
if (count($modules) > 0) {
$query = $this->connection
->delete('key_value');
$query
->condition('collection', 'system.schema');
$query
->condition('name', $modules, 'IN');
$query
->execute();
}
}