/**
  * Returns current currency code
  *
  * @return string
  */
 protected function getCurrentCurrencyId()
 {
     if (!isset($this->currency)) {
         if (\XLite\Core\Request::getInstance()->currency) {
             $this->currency = \XLite\Core\Database::getRepo('XLite\\Model\\Currency')->find(\XLite\Core\Request::getInstance()->currency);
         }
         if (!$this->currency) {
             $this->currency = \XLite::getInstance()->getCurrency();
         }
     }
     return $this->currency->getCurrencyId();
 }
Exemple #2
0
 /**
  * Format currency as parts 
  * 
  * @param float                 $value    Value
  * @param \XLite\Model\Currency $currency Currency
  *  
  * @return array
  */
 public function formatParts($value, \XLite\Model\Currency $currency)
 {
     $value = $currency->roundValue($value);
     $parts = array();
     if (0 > $value) {
         $parts['sign'] = '-';
     }
     if (!$currency->getPrefix() && !$currency->getSuffix()) {
         $parts['prefix'] = $currency->getCode();
     } elseif ($currency->getPrefix()) {
         $parts['prefix'] = $currency->getPrefix();
     }
     $parts['integer'] = number_format(floor(abs($value)), 0, '', $currency->getThousandDelimiter());
     if (0 < $currency->getE()) {
         $parts['decimalDelimiter'] = $currency->getDecimalDelimiter();
         $parts['decimal'] = substr(strval(abs($value != 0 ? $value : 1) * pow(10, $currency->getE())), -1 * $currency->getE());
     }
     if ($currency->getSuffix()) {
         $parts['suffix'] = $currency->getSuffix();
     }
     return $parts;
 }
Exemple #3
0
 /**
  * Returns option name
  *
  * @param \XLite\Model\Currency $currency Currency
  *
  * @return string
  */
 protected function getOptionName($currency)
 {
     return sprintf('%s - %s', $currency->getCode(), $currency->getName());
 }
 /**
  * {@inheritDoc}
  */
 public function prepareEntityBeforeCommit($type)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'prepareEntityBeforeCommit', array($type));
     return parent::prepareEntityBeforeCommit($type);
 }