New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Currency improvements #1780

Merged
merged 15 commits into from Dec 7, 2015
Next

Currency symbol position

  • Loading branch information...
gillesbourgeat committed Nov 12, 2015
commit 619d585cde52adc8d60f46c4d86cdb7f0cd682ac
@@ -57,6 +57,7 @@ public function create(CurrencyCreateEvent $event)
->setLocale($event->getLocale())
->setName($event->getCurrencyName())
->setSymbol($event->getSymbol())
->setFormat($event->getFormat())
->setRate($event->getRate())
->setCode(strtoupper($event->getCode()))
->setByDefault($isDefault)
@@ -80,6 +81,7 @@ public function update(CurrencyUpdateEvent $event)
->setLocale($event->getLocale())
->setName($event->getCurrencyName())
->setSymbol($event->getSymbol())
->setFormat($event->getFormat())
->setRate($event->getRate())
->setCode(strtoupper($event->getCode()))
@@ -172,7 +174,7 @@ public function updateRates(CurrencyUpdateRateEvent $event)
/**
* Changes position, selecting absolute ou relative change.
*
* @param CategoryChangePositionEvent $event
* @param UpdatePositionEvent $event
*/
public function updatePosition(UpdatePositionEvent $event)
{
@@ -63,6 +63,7 @@ protected function getCreationEvent($formData)
->setCurrencyName($formData['name'])
->setLocale($formData["locale"])
->setSymbol($formData['symbol'])
->setFormat($formData['format'])
->setCode($formData['code'])
->setRate($formData['rate'])
;
@@ -79,6 +80,7 @@ protected function getUpdateEvent($formData)
->setCurrencyName($formData['name'])
->setLocale($formData["locale"])
->setSymbol($formData['symbol'])
->setFormat($formData['format'])
->setCode($formData['code'])
->setRate($formData['rate'])
;
@@ -114,6 +116,7 @@ protected function hydrateObjectForm($object)
'locale' => $object->getLocale(),
'code' => $object->getCode(),
'symbol' => $object->getSymbol(),
'format' => $object->getFormat(),
'rate' => $object->getRate()
);
@@ -17,6 +17,7 @@ class CurrencyCreateEvent extends CurrencyEvent
protected $currency_name;
protected $locale;
protected $symbol;
protected $format;
protected $code;
protected $rate;
@@ -57,6 +58,18 @@ public function setSymbol($symbol)
return $this;
}
public function getFormat()
{
return $this->format;
}
public function setFormat($format)
{
$this->format = $format;
return $this;
}
public function getCode()
{
return $this->code;
@@ -166,6 +166,7 @@ public function parseResults(LoopResult $loopResult)
->set("NAME", $currency->getVirtualColumn('i18n_NAME'))
->set("ISOCODE", $currency->getCode())
->set("SYMBOL", $currency->getSymbol())
->set("FORMAT", $currency->getFormat())
->set("RATE", $currency->getRate())
->set("POSITION", $currency->getPosition())
->set("IS_DEFAULT", $currency->getByDefault())
@@ -46,6 +46,15 @@ protected function buildForm($change_mode = false)
"for" => "symbol",
]
])
->add("format", "text", [
"constraints" => [
new NotBlank(),
],
"label" => Translator::getInstance()->trans('Format *'),
"label_attr" => [
"for" => "format",
]
])
->add("rate", "text", [
"constraints" => [
new NotBlank(),
@@ -83,6 +83,12 @@
*/
protected $symbol;
/**
* The value for the format field.
* @var string
*/
protected $format;
/**
* The value for the rate field.
* @var double
@@ -486,6 +492,17 @@ public function getSymbol()
return $this->symbol;
}
/**
* Get the [format] column value.
*
* @return string
*/
public function getFormat()
{
return $this->format;
}
/**
* Get the [rate] column value.
*
@@ -622,6 +639,27 @@ public function setSymbol($v)
return $this;
} // setSymbol()
/**
* Set the value of [format] column.
*
* @param string $v new value
* @return \Thelia\Model\Currency The current object (for fluent API support)
*/
public function setFormat($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->format !== $v) {
$this->format = $v;
$this->modifiedColumns[CurrencyTableMap::FORMAT] = true;
}
return $this;
} // setFormat()
/**
* Set the value of [rate] column.
*
@@ -773,22 +811,25 @@ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = Ta
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CurrencyTableMap::translateFieldName('Symbol', TableMap::TYPE_PHPNAME, $indexType)];
$this->symbol = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CurrencyTableMap::translateFieldName('Rate', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CurrencyTableMap::translateFieldName('Format', TableMap::TYPE_PHPNAME, $indexType)];
$this->format = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CurrencyTableMap::translateFieldName('Rate', TableMap::TYPE_PHPNAME, $indexType)];
$this->rate = (null !== $col) ? (double) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CurrencyTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CurrencyTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
$this->position = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CurrencyTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CurrencyTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)];
$this->by_default = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CurrencyTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CurrencyTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CurrencyTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CurrencyTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
@@ -801,7 +842,7 @@ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = Ta
$this->ensureConsistency();
}
return $startcol + 8; // 8 = CurrencyTableMap::NUM_HYDRATE_COLUMNS.
return $startcol + 9; // 9 = CurrencyTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\Currency object", 0, $e);
@@ -1125,6 +1166,9 @@ protected function doInsert(ConnectionInterface $con)
if ($this->isColumnModified(CurrencyTableMap::SYMBOL)) {
$modifiedColumns[':p' . $index++] = '`SYMBOL`';
}
if ($this->isColumnModified(CurrencyTableMap::FORMAT)) {
$modifiedColumns[':p' . $index++] = '`FORMAT`';
}
if ($this->isColumnModified(CurrencyTableMap::RATE)) {
$modifiedColumns[':p' . $index++] = '`RATE`';
}
@@ -1160,6 +1204,9 @@ protected function doInsert(ConnectionInterface $con)
case '`SYMBOL`':
$stmt->bindValue($identifier, $this->symbol, PDO::PARAM_STR);
break;
case '`FORMAT`':
$stmt->bindValue($identifier, $this->format, PDO::PARAM_STR);
break;
case '`RATE`':
$stmt->bindValue($identifier, $this->rate, PDO::PARAM_STR);
break;
@@ -1247,18 +1294,21 @@ public function getByPosition($pos)
return $this->getSymbol();
break;
case 3:
return $this->getRate();
return $this->getFormat();
break;
case 4:
return $this->getPosition();
return $this->getRate();
break;
case 5:
return $this->getByDefault();
return $this->getPosition();
break;
case 6:
return $this->getCreatedAt();
return $this->getByDefault();
break;
case 7:
return $this->getCreatedAt();
break;
case 8:
return $this->getUpdatedAt();
break;
default:
@@ -1293,11 +1343,12 @@ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColum
$keys[0] => $this->getId(),
$keys[1] => $this->getCode(),
$keys[2] => $this->getSymbol(),
$keys[3] => $this->getRate(),
$keys[4] => $this->getPosition(),
$keys[5] => $this->getByDefault(),
$keys[6] => $this->getCreatedAt(),
$keys[7] => $this->getUpdatedAt(),
$keys[3] => $this->getFormat(),
$keys[4] => $this->getRate(),
$keys[5] => $this->getPosition(),
$keys[6] => $this->getByDefault(),
$keys[7] => $this->getCreatedAt(),
$keys[8] => $this->getUpdatedAt(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
@@ -1364,18 +1415,21 @@ public function setByPosition($pos, $value)
$this->setSymbol($value);
break;
case 3:
$this->setRate($value);
$this->setFormat($value);
break;
case 4:
$this->setPosition($value);
$this->setRate($value);
break;
case 5:
$this->setByDefault($value);
$this->setPosition($value);
break;
case 6:
$this->setCreatedAt($value);
$this->setByDefault($value);
break;
case 7:
$this->setCreatedAt($value);
break;
case 8:
$this->setUpdatedAt($value);
break;
} // switch()
@@ -1405,11 +1459,12 @@ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setSymbol($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setRate($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setByDefault($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
if (array_key_exists($keys[3], $arr)) $this->setFormat($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setRate($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setPosition($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setByDefault($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
}
/**
@@ -1424,6 +1479,7 @@ public function buildCriteria()
if ($this->isColumnModified(CurrencyTableMap::ID)) $criteria->add(CurrencyTableMap::ID, $this->id);
if ($this->isColumnModified(CurrencyTableMap::CODE)) $criteria->add(CurrencyTableMap::CODE, $this->code);
if ($this->isColumnModified(CurrencyTableMap::SYMBOL)) $criteria->add(CurrencyTableMap::SYMBOL, $this->symbol);
if ($this->isColumnModified(CurrencyTableMap::FORMAT)) $criteria->add(CurrencyTableMap::FORMAT, $this->format);
if ($this->isColumnModified(CurrencyTableMap::RATE)) $criteria->add(CurrencyTableMap::RATE, $this->rate);
if ($this->isColumnModified(CurrencyTableMap::POSITION)) $criteria->add(CurrencyTableMap::POSITION, $this->position);
if ($this->isColumnModified(CurrencyTableMap::BY_DEFAULT)) $criteria->add(CurrencyTableMap::BY_DEFAULT, $this->by_default);
@@ -1494,6 +1550,7 @@ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setCode($this->getCode());
$copyObj->setSymbol($this->getSymbol());
$copyObj->setFormat($this->getFormat());
$copyObj->setRate($this->getRate());
$copyObj->setPosition($this->getPosition());
$copyObj->setByDefault($this->getByDefault());
@@ -3004,6 +3061,7 @@ public function clear()
$this->id = null;
$this->code = null;
$this->symbol = null;
$this->format = null;
$this->rate = null;
$this->position = null;
$this->by_default = null;
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.