You are here

public static function MessageMultipleDeleteForm::deleteMessages in Message UI 8

Delete multiple messages.

Parameters

array $mids: The message IDS.

array $sandbox: The sandbo object of the batch operation.

File

src/Form/MessageMultipleDeleteForm.php, line 133

Class

MessageMultipleDeleteForm
Class MessageMultipleDeleteForm.

Namespace

Drupal\message_ui\Form

Code

public static function deleteMessages(array $mids, array &$sandbox) {
  $messages = \Drupal::entityTypeManager()
    ->getStorage('message')
    ->loadMultiple($mids);
  $sandbox['message'] = t('Deleting messages between @start ot @end', [
    '@start' => reset($mids),
    '@end' => end($mids),
  ]);
  \Drupal::entityTypeManager()
    ->getStorage('message')
    ->delete($messages);
}