You are here

public function VersionMismatches::aggregate in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x modules/cms_content_sync_health/src/Controller/VersionMismatches.php \Drupal\cms_content_sync_health\Controller\VersionMismatches::aggregate()
  2. 2.0.x modules/cms_content_sync_health/src/Controller/VersionMismatches.php \Drupal\cms_content_sync_health\Controller\VersionMismatches::aggregate()

Prepare batch operation.

1 string reference to 'VersionMismatches::aggregate'
cms_content_sync_health.routing.yml in modules/cms_content_sync_health/cms_content_sync_health.routing.yml
modules/cms_content_sync_health/cms_content_sync_health.routing.yml

File

modules/cms_content_sync_health/src/Controller/VersionMismatches.php, line 19

Class

VersionMismatches
Show all version mismatches of all entity types. Can take some time to execute depending on the number of entity types configured, so is run as a batch operation.

Namespace

Drupal\cms_content_sync_health\Controller

Code

public function aggregate() {
  $operations = [];
  $entity_types = \Drupal::service('entity_type.bundle.info')
    ->getAllBundleInfo();
  ksort($entity_types);
  foreach ($entity_types as $type_key => $entity_type) {
    if (substr($type_key, 0, 16) == 'cms_content_sync') {
      continue;
    }
    ksort($entity_type);
    foreach ($entity_type as $entity_bundle_name => $entity_bundle) {
      $any_handler = FALSE;
      foreach (Flow::getAll() as $id => $flow) {
        $config = $flow
          ->getEntityTypeConfig($type_key, $entity_bundle_name, TRUE);
        if (empty($config) || $config['handler'] == Flow::HANDLER_IGNORE) {
          continue;
        }
        $any_handler = TRUE;
        break;
      }
      if (!$any_handler) {
        continue;
      }
      $operations[] = [
        '\\Drupal\\cms_content_sync_health\\Controller\\VersionMismatches::batch',
        [
          $type_key,
          $entity_bundle_name,
        ],
      ];
    }
  }
  $batch = [
    'title' => t('Check version mismatches...'),
    'operations' => $operations,
    'finished' => '\\Drupal\\cms_content_sync_health\\Controller\\VersionMismatches::batchFinished',
  ];
  batch_set($batch);
  return batch_process();
}