You are here

function drush_acsf_duplication_scrub_progress in Acquia Cloud Site Factory Connector 8

Command callback. Outputs progress information on the site duplication scrub.

File

acsf_duplication/acsf_duplication.drush.inc, line 105
Provides drush commands necessary for site duplication.

Code

function drush_acsf_duplication_scrub_progress() {
  if (!\Drupal::moduleHandler()
    ->moduleExists('acsf')) {
    return drush_set_error(dt('The ACSF module must be enabled.'));
  }

  // Get remaining count from the handlers. (Note this code highlights the fact
  // that the countRemaining() method does not return different results
  // depending on whether we pass in a proper event/context; if it does, we'll
  // return bogus results.)
  $empty_event = AcsfEvent::create('site_duplication_scrub');
  $data = [];
  $handler = new AcsfDuplicationScrubCommentHandler($empty_event);
  $data['comment_count'] = $handler
    ->countRemaining();
  $handler = new AcsfDuplicationScrubNodeHandler($empty_event);
  $data['node_count'] = $handler
    ->countRemaining();
  $handler = new AcsfDuplicationScrubUserHandler($empty_event);
  $data['user_count'] = $handler
    ->countRemaining();
  \Drupal::moduleHandler()
    ->alter('acsf_duplication_scrub_remaining_counts', $data);
  $format = drush_get_option('format', 'var_export');
  drush_print(drush_format($data, NULL, $format));
}