public function SimpleNodeImporterConfigForm::submitFormDeleteLogs in Simple Node Importer 8
Delete import logs.
1 call to SimpleNodeImporterConfigForm::submitFormDeleteLogs()
- SimpleNodeImporterConfigForm::submitForm in src/
Form/ SimpleNodeImporterConfigForm.php - Form submission handler.
File
- src/
Form/ SimpleNodeImporterConfigForm.php, line 188
Class
- SimpleNodeImporterConfigForm
- Configuration Form for the Simple Node Importer.
Namespace
Drupal\simple_node_importer\FormCode
public function submitFormDeleteLogs(array &$form, FormStateInterface $form_state) {
if ($this->checkAvailablity) {
$node_setting = $form_state
->getValue([
'node_delete',
'deletelog',
]);
$bundle = 'simple_node';
$query = \Drupal::entityQuery('node');
$query
->condition('status', 1);
$query
->condition('type', $bundle);
$nids = $query
->execute();
if ($node_setting === 'deletelog' && !empty($nids)) {
entity_delete_multiple('node', $nids);
drupal_set_message($this
->t('%count nodes has been deleted.', [
'%count' => count($nids),
]));
}
elseif ($node_setting === 'deletelog' && empty($nids)) {
drupal_set_message($this
->t("Oops there is nothing to delete"));
}
}
}