SearchIndexWipeConfirm.php in Search Index Wipe 8
File
src/Form/SearchIndexWipeConfirm.php
View source
<?php
namespace Drupal\searchindex_wipe\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class SearchIndexWipeConfirm extends ConfirmFormBase {
public function getFormId() {
return 'searchindex_wipe_confirm';
}
public function getQuestion() {
return $this
->t('Are you sure you want to clearing of Search related indexes?');
}
public function getConfirmText() {
return $this
->t('Delete');
}
public function getCancelUrl() {
return new Url('entity.search_page.collection');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
if ($form['confirm']) {
searchindex_wipe_truncate_table();
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
}
}