Same name and namespace in other branches
- 3.0.x src/Feeds/Target/Color.php \Drupal\color_field\Feeds\Target\Color::prepareValue()
Fichier
-
src/
Feeds/ Target/ Color.php, line 35
Classe
- Color
- Defines a color field mapper.
Namespace
Drupal\color_field\Feeds\TargetCode
protected function prepareValue($delta, array &$values) {
// Clean up data and format it.
$color = trim($values['color']);
if (substr($color, 0, 1) === '#') {
$color = substr($color, 1);
}
switch ($this->configuration['format']) {
case '#HEXHEX':
$color = '#' . strtoupper($color);
break;
case 'HEXHEX':
$color = strtoupper($color);
break;
case '#hexhex':
$color = '#' . strtolower($color);
break;
case 'hexhex':
$color = strtolower($color);
break;
}
$values['color'] = $color;
$values['opacity'] = $values['opacity'] ? (double) $values['opacity'] : 0.0;
}