You are here

public function ContentHubEntityLinkFieldHandler::normalizeItems in Acquia Content Hub 8

Converts Entity IDs into UUIDs.

Parameters

array $items: An array of field value items.

Return value

array an array of field values that Replaces IDs with UUIDs.

File

src/ContentHubEntityLinkFieldHandler.php, line 68

Class

ContentHubEntityLinkFieldHandler
Content Hub Entity Link Field.

Namespace

Drupal\acquia_contenthub

Code

public function normalizeItems(array $items) {
  $link_entities = $this
    ->getReferencedEntities($items);
  foreach ($items as $key => $item) {
    if (isset($link_entities[$key])) {
      $uri = $item['uri'];
      $link_parts = pathinfo($uri);
      $items[$key]['uri'] = $link_parts['dirname'] . '/' . $link_entities[$key]
        ->uuid();
    }
  }
  return $items;
}