You are here

function drush_push_notifications_clear_push_notifications in Push Notifications 8

Drush command logic.

File

./push_notifications.drush.inc, line 30
Contains the code to generate drush commands

Code

function drush_push_notifications_clear_push_notifications($target = NULL) {
  switch ($target) {
    case 'push-notification':
      $push_notification_ids = \Drupal::entityQuery('push_notification')
        ->execute();
      entity_delete_multiple('push_notification', $push_notification_ids);
      drush_print('All push notifications have been removed.');
      break;
    case 'push-notifications-token':
      $push_notifications_tokens_ids = \Drupal::entityQuery('push_notifications_token')
        ->execute();
      entity_delete_multiple('push_notifications_token', $push_notifications_tokens_ids);
      drush_print('All push notifications tokens have been removed.');
      break;
    case 'all':
      $push_notification_ids = \Drupal::entityQuery('push_notification')
        ->execute();
      $push_notifications_tokens_ids = \Drupal::entityQuery('push_notifications_token')
        ->execute();
      entity_delete_multiple('push_notification', $push_notification_ids);
      entity_delete_multiple('push_notifications_token', $push_notifications_tokens_ids);
      drush_print('All push notifications and push notifications tokens have been removed.');
      break;
    default:
      drush_print('Wrong argument, run "drush clear-pn --help" to see available arguments.');
  }
}