public function BulkDeleteForm::buildForm in Bulk Delete 8
@todo, displays last backup timestamp
Overrides FormInterface::buildForm
File
- src/
Form/ BulkDeleteForm.php, line 52
Class
- BulkDeleteForm
- BackupDatabaseForm class.
Namespace
Drupal\bulkdelete\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$options = [];
// Get list of content type.
$types = NodeType::loadMultiple();
ksort($types);
foreach ($types as $key => $values) {
$query = \Drupal::entityQuery('node')
->condition('type', $key)
->count();
$count = $query
->execute();
if ($count > 0) {
$options[$key] = $values
->get('name') . " ({$count})";
}
}
if (empty($options)) {
$form['default_msg'] = [
'#type' => 'item',
'#markup' => $this
->t('Node not available.'),
];
}
else {
$form['types'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Content types for deletion'),
'#options' => $options,
'#description' => $this
->t('All nodes of these types will be deleted using the batch API.'),
];
$form['actions']['#type'] = 'actions';
$form['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Delete'),
'#button_type' => 'primary',
];
}
return $form;
}