You are here

protected static function ContentLinksForm::getUriAsDisplayableString in General Data Protection Regulation 8

Same name and namespace in other branches
  1. 8.2 src/Form/ContentLinksForm.php \Drupal\gdpr\Form\ContentLinksForm::getUriAsDisplayableString()
  2. 3.0.x src/Form/ContentLinksForm.php \Drupal\gdpr\Form\ContentLinksForm::getUriAsDisplayableString()

Gets the URI without the 'internal:' or 'entity:' scheme.

The following two forms of URIs are transformed:

  • 'entity:' URIs: to entity autocomplete ("label (entity id)") strings;
  • 'internal:' URIs: the scheme is stripped.

This method is the inverse of ::getUserEnteredStringAsUri().

Parameters

string $uri: The URI to get the displayable string for.

Return value

string The displayable URI.

See also

static::getUserEnteredStringAsUri()

1 call to ContentLinksForm::getUriAsDisplayableString()
ContentLinksForm::loadUrls in src/Form/ContentLinksForm.php
Load the stored URLs as displayable strings.

File

src/Form/ContentLinksForm.php, line 181

Class

ContentLinksForm
Class ContentLinksForm.

Namespace

Drupal\gdpr\Form

Code

protected static function getUriAsDisplayableString($uri) {
  $scheme = \parse_url($uri, PHP_URL_SCHEME);

  // By default, the displayable string is the URI.
  $displayableString = $uri;

  // A different displayable string may be chosen in case of the 'internal:'
  // or 'entity:' built-in schemes.
  if ($scheme === 'internal') {
    $uriReference = \explode(':', $uri, 2)[1];

    // @todo '<front>' is valid input for BC reasons, may be removed by
    //   https://www.drupal.org/node/2421941
    $path = \parse_url($uri, PHP_URL_PATH);
    if ($path === '/') {
      $uriReference = '<front>' . \substr($uriReference, 1);
    }
    $displayableString = $uriReference;
  }
  return $displayableString;
}