You are here

function _cms_content_sync_display_pool_usage in CMS Content Sync 8

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

Get HTML for a list of the usage for the given entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity:

Return value

string

Throws

Exception

3 calls to _cms_content_sync_display_pool_usage()
cms_content_sync_form_alter in ./cms_content_sync.module
1) Make sure the user is informed that content will not only be deleted on this * instance but also on all connected instances if configured that way.
ShowUsage::content in src/Controller/ShowUsage.php
_cms_content_sync_display_usage in ./cms_content_sync.module
Replace the "Show usage" button with the actual usage information.

File

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

Code

function _cms_content_sync_display_pool_usage($entity) {
  $usages = Pool::getAllExternalUsages($entity);
  if (empty($usages)) {
    return '';
  }
  $result = '';
  foreach ($usages as $pool_id => $usage) {
    if (empty($usage)) {
      continue;
    }
    $pool = Pool::getAll()[$pool_id];
    $result .= '<br><b>Pool: ' . $pool->label . '</b><ul>';
    foreach ($usage as $site_id => $url) {
      $name = $pool
        ->getClient()
        ->getSiteName($site_id);
      if (!$name) {
        $name = $site_id;
      }
      if ($url) {
        $text = '<a href="' . $url . '">' . $name . '</a>';
      }
      else {
        $text = $name;
      }
      $result .= '<li>' . $text . '</li>';
    }
    $result .= '</ul>';
  }
  if (empty($result)) {
    return $result;
  }
  return '</ul>' . $result . '</ul>';
}