You are here

protected function Path::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/Path.php, line 36

Class

Path
Defines a path field mapper.

Namespace

Drupal\feeds\Feeds\Target

Code

protected function prepareValue($delta, array &$values) {
  if (array_key_exists('pathauto', $values)) {
    $values['pathauto'] = (int) (bool) $values['pathauto'];
  }
  else {
    $values['pathauto'] = 0;
  }
  $values['alias'] = trim($values['alias']);

  // Check if the alias is conform the regex.
  if (strlen($values['alias']) && !preg_match('/^\\//i', $values['alias'])) {

    // Correct the alias by adding a slash.
    $values['alias'] = '/' . $values['alias'];
  }
}