You are here

public function CourierMaintenanceForm::submitForm in Courier 8

Same name and namespace in other branches
  1. 2.x src/Form/CourierMaintenanceForm.php \Drupal\courier\Form\CourierMaintenanceForm::submitForm()

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/CourierMaintenanceForm.php, line 86
Contains \Drupal\courier\Form\CourierMaintenanceForm.

Class

CourierMaintenanceForm
Courier maintenance form.

Namespace

Drupal\courier\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $time = REQUEST_TIME - $form_state
    ->getValue('delete_age');
  $storage = $this->entityTypeManager
    ->getStorage('courier_message_queue_item');
  $ids = $storage
    ->getQuery()
    ->condition('created', $time, '<')
    ->execute();
  $storage
    ->delete($storage
    ->loadMultiple($ids));
  drupal_set_message($this
    ->formatPlural(count($ids), '@count message deleted.', '@count messages deleted.'));
}