You are here

protected function SyncHealth::countEntitiesWithChangedVersionForPush in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x 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
      ->getEntityTypeConfig(NULL, NULL, TRUE) as $id => $config) {
      if (in_array($id, $checked)) {
        continue;
      }
      $checked[] = $id;
      $type_name = $config['entity_type_name'];
      $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;
}