BackupDatabaseHistoryForm.php in Backup Database 8
File
src/Form/BackupDatabaseHistoryForm.php
View source
<?php
namespace Drupal\backup_db\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\FormBase;
class BackupDatabaseHistoryForm extends FormBase {
public function getFormId() {
return 'backup_db_history';
}
public function buildForm(array $form, FormStateInterface $form_state, $rows = array()) {
$header = array(
'fid' => 'fid',
'name' => t('Name'),
'location' => t('Location'),
'created' => t('Created'),
);
$form['table'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $rows,
'#empty' => t('No local export history found.'),
);
if ($rows) {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
);
}
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
$files = array_filter($values['table']);
foreach ($files as $file) {
backup_db_history_delete($file);
}
}
}