You are here

public static function Pool::getAllExternalUsages in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x src/Entity/Pool.php \Drupal\cms_content_sync\Entity\Pool::getAllExternalUsages()
  2. 2.0.x src/Entity/Pool.php \Drupal\cms_content_sync\Entity\Pool::getAllExternalUsages()

Get a list of all sites for all pools that are using this entity. Only works for pools that are connected to the entity on this site.

Parameters

\Drupal\Core\Entity\EntityInterface $entity:

Return value

array pool => site_id[]

Throws

\Exception

\GuzzleHttp\Exception\GuzzleException

1 call to Pool::getAllExternalUsages()
_cms_content_sync_display_pool_usage in ./cms_content_sync.module
Get HTML for a list of the usage for the given entity.

File

src/Entity/Pool.php, line 175

Class

Pool
Defines the "Content Sync - Pool" entity.

Namespace

Drupal\cms_content_sync\Entity

Code

public static function getAllExternalUsages($entity) {
  $entity_type = $entity
    ->getEntityTypeId();
  $bundle = $entity
    ->bundle();
  $entity_uuid = $entity
    ->uuid();
  $result = [];
  foreach (EntityStatus::getInfosForEntity($entity_type, $entity_uuid) as $status) {
    $pool = $status
      ->getPool();
    if (empty($pool)) {
      continue;
    }
    $pool_id = $pool->id;
    if (isset($result[$pool_id])) {
      continue;
    }
    if ($entity instanceof ConfigEntityInterface) {
      $shared_entity_id = $entity
        ->id();
    }
    else {
      $shared_entity_id = $entity_uuid;
    }
    $result[$pool_id] = $pool
      ->getClient()
      ->getSyndicationService()
      ->getExternalUsages($pool_id, $entity_type, $bundle, $shared_entity_id);
  }
  return $result;
}