public function PrepareUninstallForm::submitForm in Commerce Stock 8
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/
local_storage/ src/ Form/ PrepareUninstallForm.php, line 86
Class
- PrepareUninstallForm
- The always in stock field uninstall form.
Namespace
Drupal\commerce_stock_local\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$tables_to_update = [];
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type) {
if ($entity_type
->isSubclassOf('\\Drupal\\commerce\\PurchasableEntityInterface')) {
$tables_to_update[] = $entity_type
->getDataTable();
$tables_to_update[] = $entity_type
->getRevisionDataTable();
}
}
$db_connection = Database::getConnection();
foreach ($tables_to_update as $table) {
if ($table && $db_connection
->schema()
->fieldExists($table, 'commerce_stock_always_in_stock')) {
$db_connection
->update($table)
->fields([
'commerce_stock_always_in_stock' => NULL,
])
->execute();
}
}
\Drupal::messenger()
->addMessage(t('All values have been deleted.'));
$form_state
->setRedirect('system.modules_uninstall');
}