You are here

public function DownloadCountClearForm::submitForm in Download Count 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

src/Form/DownloadCountClearForm.php, line 60

Class

DownloadCountClearForm
Remove form for book module.

Namespace

Drupal\download_count\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  Drupal::service('config.factory')
    ->getEditable('download_count.settings')
    ->set('download_count_last_cron', 0)
    ->save();
  Drupal::database()
    ->truncate('download_count_cache')
    ->execute();
  drupal_set_message($this
    ->t('The download count cache has been cleared.'));
  Drupal::logger('download_count')
    ->notice($this
    ->t('The download count cache has been cleared.'));
  $form_state
    ->setRedirect('download_count.file_settings');
}