You are here

function hacked_calculate_project_data_drush in Hacked! 8.2

Same name and namespace in other branches
  1. 6.2 hacked.drush.inc \hacked_calculate_project_data_drush()
  2. 7.2 hacked.drush.inc \hacked_calculate_project_data_drush()

Compute the report data for hacked.

WARNING: This function can invoke a batch process and end your current page. So you'll want to be very careful if you call this!

Parameters

array $projects: An array of Drupal projects.

bool|FALSE $force: If TRUE, force rebuild of project data.

2 calls to hacked_calculate_project_data_drush()
drush_hacked_list_projects in ./hacked.drush.inc
Drush command callback that shows the listing of changed/unchanged projects.
drush_hacked_lock_modified in ./hacked.drush.inc
Lock all of the modified files so that pm-updatecode will not touch them.

File

./hacked.drush.inc, line 85
Hacked drush command.

Code

function hacked_calculate_project_data_drush($projects, $force = FALSE) {
  include_once DRUPAL_ROOT . '/core/includes/batch.inc';

  // Try to get the report form cache if we can.
  $cache = \Drupal::cache(HACKED_CACHE_TABLE)
    ->get('hacked:drush:full-report');
  if (!empty($cache->data) && !$force) {
    return $cache->data;
  }

  // Enter a batch to build the report.
  $operations = [];
  foreach ($projects as $project) {
    $operations[] = [
      'hacked_build_report_batch',
      [
        $project['name'],
      ],
    ];
  }
  $batch = [
    'operations' => $operations,
    'finished' => 'hacked_build_report_batch_finished_drush',
    'file' => drupal_get_path('module', 'hacked') . '/hacked.report.inc',
    'title' => t('Building report'),
  ];
  drush_print('Rebuilding Hacked! report');
  batch_set($batch);
  $batch =& batch_get();
  $batch['progressive'] = FALSE;
  drush_backend_batch_process();
  drush_print('Done.');

  // Now we can get the data from the cache.
  $cache = \Drupal::cache(HACKED_CACHE_TABLE)
    ->get('hacked:drush:full-report');
  if (!empty($cache->data)) {
    return $cache->data;
  }
}