You are here

protected function LinkInternalContentImporter::processLink in Entity Share 8.3

Attempts to import UUID-enhanced link content.

Parameters

\Drupal\entity_share_client\RuntimeImportContext $runtime_import_context: The import context.

string $uri: URI should be in the format entity:[entity_type]/[bundle_name]/[UUID].

string $import_url: The import URL prepared by the entity_share_uuid_link enhancer plugin.

Return value

string Link to the imported content in the form entity:[entity_type]/[Id].

1 call to LinkInternalContentImporter::processLink()
LinkInternalContentImporter::prepareImportableEntityData in modules/entity_share_client/src/Plugin/EntityShareClient/Processor/LinkInternalContentImporter.php
Method called on STAGE_PREPARE_IMPORTABLE_ENTITY_DATA.

File

modules/entity_share_client/src/Plugin/EntityShareClient/Processor/LinkInternalContentImporter.php, line 63

Class

LinkInternalContentImporter
Import internal content from Link fields.

Namespace

Drupal\entity_share_client\Plugin\EntityShareClient\Processor

Code

protected function processLink(RuntimeImportContext $runtime_import_context, string $uri, string $import_url) {

  // Check if it is a link to an entity.
  preg_match("/entity:(.*)\\/(.*)\\/(.*)/", $uri, $parsed_uri);

  // If the link is not in UUID enhanced format, just return the original URI.
  if (empty($parsed_uri)) {
    return $uri;
  }
  $entity_type = $parsed_uri[1];
  $entity_uuid = $parsed_uri[3];
  $referenced_entities_ids = $this
    ->importUrl($runtime_import_context, $import_url);
  if (!empty($referenced_entities_ids) && isset($referenced_entities_ids[$entity_uuid])) {
    return 'entity:' . $entity_type . '/' . $referenced_entities_ids[$entity_uuid];
  }
  else {
    return $uri;
  }
}