You are here

protected function SyncHealth::countEntitiesWithChangedVersionForPush in CMS Content Sync 2.1.x

Same name and namespace in other branches
  1. 8 modules/cms_content_sync_health/src/Controller/SyncHealth.php \Drupal\cms_content_sync_health\Controller\SyncHealth::countEntitiesWithChangedVersionForPush()
  2. 2.0.x modules/cms_content_sync_health/src/Controller/SyncHealth.php \Drupal\cms_content_sync_health\Controller\SyncHealth::countEntitiesWithChangedVersionForPush()
1 call to SyncHealth::countEntitiesWithChangedVersionForPush()
SyncHealth::pushing in modules/cms_content_sync_health/src/Controller/SyncHealth.php
Render the overview page.

File

modules/cms_content_sync_health/src/Controller/SyncHealth.php, line 446

Class

SyncHealth
Provides a listing of Flow.

Namespace

Drupal\cms_content_sync_health\Controller

Code

protected function countEntitiesWithChangedVersionForPush() {
  $checked = [];
  $versions = [];
  $types = [];
  foreach (Flow::getAll() as $flow) {
    foreach ($flow
      ->getController()
      ->getEntityTypeConfig(NULL, NULL, TRUE) as $type_name => $bundles) {
      foreach ($bundles as $bundle_name => $config) {
        $id = $type_name . "\n" . $bundle_name;
        if (in_array($id, $checked)) {
          continue;
        }
        $checked[] = $id;
        $version = $config['version'];
        if (!in_array($type_name, $types)) {
          $types[] = $type_name;
        }
        $versions[] = $version;
      }
    }
  }
  $count = $this->database
    ->select('cms_content_sync_entity_status')
    ->condition('entity_type', $types, 'IN')
    ->condition('entity_type_version', $versions, 'NOT IN')
    ->where('flags&:flag=:flag', [
    ':flag' => EntityStatus::FLAG_IS_SOURCE_ENTITY,
  ])
    ->countQuery()
    ->execute()
    ->fetchField();
  return $count;
}