protected static function ContentLinksForm::getUserEnteredStringAsUri in General Data Protection Regulation 8.2
Same name and namespace in other branches
- 8 src/Form/ContentLinksForm.php \Drupal\gdpr\Form\ContentLinksForm::getUserEnteredStringAsUri()
- 3.0.x src/Form/ContentLinksForm.php \Drupal\gdpr\Form\ContentLinksForm::getUserEnteredStringAsUri()
Gets the user-entered string as a URI.
The following two forms of input are mapped to URIs:
- entity autocomplete ("label (entity id)") strings: to 'entity:' URIs;
- strings without a detectable scheme: to 'internal:' URIs.
This method is the inverse of ::getUriAsDisplayableString().
Parameters
string $string: The user-entered string.
Return value
string The URI, if a non-empty $uri was passed.
See also
static::getUriAsDisplayableString()
1 call to ContentLinksForm::getUserEnteredStringAsUri()
- ContentLinksForm::validateUriElement in src/
Form/ ContentLinksForm.php - Form element validation handler for the 'uri' element.
File
- src/
Form/ ContentLinksForm.php, line 252
Class
- ContentLinksForm
- Class ContentLinksForm.
Namespace
Drupal\gdpr\FormCode
protected static function getUserEnteredStringAsUri($string) {
// By default, assume the entered string is an URI.
$uri = $string;
if (!empty($string) && parse_url($string, PHP_URL_SCHEME) === NULL) {
// @todo '<front>' is valid input for BC reasons, may be removed by
// https://www.drupal.org/node/2421941
// - '<front>' -> '/'
// - '<front>#foo' -> '/#foo'
if (strpos($string, '<front>') === 0) {
$string = '/' . substr($string, strlen('<front>'));
}
$uri = 'internal:' . $string;
}
return $uri;
}