You are here

public function ContentHubReindex::getExportedEntitiesNotOwnedByThisSite in Acquia Content Hub 8

Obtains a list of entities exported to Content Hub not owned by this site.

For the specific entity type, it queries Content Hub and checks if the previously exported entities belong to this exporting site origin or they have been exported by other sites.

Limitation: This check uses the "listEntities" method from ContentHubClient without using pagination, so it will only check for the first 1000 entities returned by this list. It will need to be improved at some point to deal with pagination.

Parameters

string|null $entity_type_id: The entity type ID.

Return value

array An array of exported entities not owned by this site (different origin).

File

src/Controller/ContentHubReindex.php, line 281

Class

ContentHubReindex
Class for reindexing Content Hub content.

Namespace

Drupal\acquia_contenthub\Controller

Code

public function getExportedEntitiesNotOwnedByThisSite($entity_type_id = NULL) {
  $external_ownership = [];
  $options = empty($entity_type_id) ? [] : [
    'type' => $entity_type_id,
  ];
  $list = $this->clientManager
    ->createRequest('listEntities', [
    $options,
  ]);
  if (isset($list['success']) && $list['success'] && isset($list['data']) && is_array($list['data'])) {
    $origin = $this->contentHubEntitiesTracking
      ->getSiteOrigin();
    foreach ($list['data'] as $entity) {
      if ($entity['origin'] !== $origin) {
        $external_ownership[] = $entity;
      }
    }
  }
  return $external_ownership;
}