You are here

function _cms_content_sync_display_entity_type_differences in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x cms_content_sync.module \_cms_content_sync_display_entity_type_differences()
  2. 2.0.x cms_content_sync.module \_cms_content_sync_display_entity_type_differences()

Get HTML for a list of entity type differences.

Parameters

string $entity_type:

string $bundle:

Return value

string

Throws

Exception

2 calls to _cms_content_sync_display_entity_type_differences()
_cms_content_sync_display_entity_type_differences_recursively in ./cms_content_sync.module
Get HTML for a list of entity type differences and include all referenced entity types.
_cms_content_sync_display_version_mismatches in ./cms_content_sync.module
Replace the "Show version mismatches" button with the actual information.

File

./cms_content_sync.module, line 112
Module file for cms_content_sync.

Code

function _cms_content_sync_display_entity_type_differences($entity_type, $bundle) {
  $all_diffs = Pool::getAllSitesWithDifferentEntityTypeVersion($entity_type, $bundle);
  $result = '';
  foreach ($all_diffs as $pool_id => $pool_diff) {
    if (empty($pool_diff)) {
      continue;
    }
    $pool = Pool::getAll()[$pool_id];
    foreach ($pool_diff as $site_id => $diff) {
      $name = $pool
        ->getClient()
        ->getSiteName($site_id);
      if (!$name) {
        $name = $site_id;
      }
      $result .= '<li>' . $name . ' (' . $pool_id . ')<ul>';
      if (isset($diff['local_missing'])) {
        foreach ($diff['local_missing'] as $field) {
          $result .= '<li>' . t('Missing locally:') . ' ' . $field . '</li>';
        }
      }
      if (isset($diff['remote_missing'])) {
        foreach ($diff['remote_missing'] as $field) {
          $result .= '<li>' . t('Missing remotely:') . ' ' . $field . '</li>';
        }
      }
      $result .= '</ul></li>';
    }
  }
  if (empty($result)) {
    return NULL;
  }
  return '<ul>' . $result . '</ul>';
}