Returns chainability in setValue from parent

This commit is contained in:
Reece Alexander 2017-12-17 17:21:42 +10:00 committed by GitHub
parent 1c72d6946d
commit 9c91e9820e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,7 +17,6 @@ namespace SilverStripe\ORM\FieldType;
*/
class DBCurrency extends DBDecimal
{
/**
* @config
* @var string
@ -38,9 +37,9 @@ class DBCurrency extends DBDecimal
$val = $this->config()->currency_symbol . number_format(abs($this->value), 2);
if ($this->value < 0) {
return "($val)";
} else {
return $val;
}
return $val;
}
/**
@ -51,9 +50,9 @@ class DBCurrency extends DBDecimal
$val = $this->config()->currency_symbol . number_format(abs($this->value), 0);
if ($this->value < 0) {
return "($val)";
} else {
return $val;
}
return $val;
}
public function setValue($value, $record = null, $markChanged = true)
@ -62,9 +61,11 @@ class DBCurrency extends DBDecimal
if (is_numeric($value)) {
$this->value = $value;
} elseif (preg_match('/-?\$?[0-9,]+(.[0-9]+)?([Ee][0-9]+)?/', $value, $matches)) {
$this->value = str_replace(array('$',',',$this->config()->currency_symbol), '', $matches[0]);
} else {
$this->value = 0;
$this->value = str_replace(['$', ',', $this->config()->currency_symbol], '', $matches[0]);
}
$this->value = 0;
return $this;
}
}