You are here

public static function AdminUninstallForm::deletePrivateMessageMessages in Private Message 8

Same name and namespace in other branches
  1. 8.2 src/Form/AdminUninstallForm.php \Drupal\private_message\Form\AdminUninstallForm::deletePrivateMessageMessages()

Batch callback to delete private messages.

File

src/Form/AdminUninstallForm.php, line 111

Class

AdminUninstallForm
Definest he admin uninstall form for the Private Message module.

Namespace

Drupal\private_message\Form

Code

public static function deletePrivateMessageMessages(&$context) {
  $private_message_ids = \Drupal::entityQuery('private_message')
    ->range(0, 100)
    ->execute();
  $storage = \Drupal::entityManager()
    ->getStorage('private_message');
  if ($private_messages = $storage
    ->loadMultiple($private_message_ids)) {
    $storage
      ->delete($private_messages);
  }
  $context['finished'] = (int) count($private_messages) < 100;
}