protected function Password::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/ Password.php, line 88
Class
- Password
- Defines a password field mapper.
Namespace
Drupal\feeds\Feeds\TargetCode
protected function prepareValue($delta, array &$values) {
$values['value'] = trim($values['value']);
switch ($this->configuration['pass_encryption']) {
case static::PASS_UNENCRYPTED:
$values['pre_hashed'] = FALSE;
break;
case static::PASS_MD5:
$new_hash = $this->passwordHasher
->hash($values['value']);
if (!$new_hash) {
throw new TargetValidationException($this
->t('Failed to hash the password.'));
}
// Indicate an updated password.
$values['value'] = 'U' . $new_hash;
$values['pre_hashed'] = TRUE;
break;
case static::PASS_SHA512:
$values['pre_hashed'] = TRUE;
break;
}
}