protected function Link::prepareValue in Feeds 8.3
Prepares a single value.
Parameters
int $delta: The field delta.
array $values: The values.
Overrides FieldTargetBase::prepareValue
File
- src/
Feeds/ Target/ Link.php, line 31
Class
- Link
- Defines a link field mapper.
Namespace
Drupal\feeds\Feeds\TargetCode
protected function prepareValue($delta, array &$values) {
$values['uri'] = trim($values['uri']);
// Support linking to nothing.
if (in_array($values['uri'], [
'<nolink>',
'<none>',
], TRUE)) {
$values['uri'] = 'route:' . $values['uri'];
}
elseif (!empty($values['uri']) && parse_url($values['uri'], 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($values['uri'], '<front>') === 0) {
$values['uri'] = '/' . substr($values['uri'], strlen('<front>'));
}
// Prepend only with 'internal:' if the uri starts with '/', '?' or '#'.
if (in_array($values['uri'][0], [
'/',
'?',
'#',
], TRUE)) {
$values['uri'] = 'internal:' . $values['uri'];
}
}
}