Exemple #1
0
/**
 * 2015-12-28
 * @param int|string|null|bool|StoreInterface $store [optional]
 * @return array(string => string)
 */
function df_currencies_ctn($store = null)
{
    return dfcf(function ($store = null) {
        $store = df_store($store);
        /** @var Currency $currency */
        $currency = df_o(Currency::class);
        /** @var string[] $codes */
        $codes = df_currencies_codes_allowed($store);
        // 2016-02-17
        // $rates ниже не содержит базовую валюту.
        /** @var string $baseCode */
        $baseCode = $store->getBaseCurrency()->getCode();
        /** @var array(string => float) $rates */
        $rates = $currency->getCurrencyRates($store->getBaseCurrency(), $codes);
        /** @var array(string => string) $result */
        $result = [];
        foreach ($codes as $code) {
            /** @var string $code */
            if ($baseCode === $code || isset($rates[$code])) {
                $result[$code] = df_currency_name($code);
            }
        }
        return $result;
    }, func_get_args());
}
Exemple #2
0
 /**
  * 2016-06-30
  * @return Phrase
  */
 private function message()
 {
     /** @var string $namesA */
     $namesA = df_quote_russian(df_html_b(df_currency_name($this->_iso3)));
     /** @var string $namesS */
     $namesS = implode(', ', $namesA);
     /** @var string $whatToEnable */
     /** @var string $whatToSet */
     /** @var string $object */
     list($whatToEnable, $whatToSet, $object) = 1 === count($namesA) ? ["the {$namesS} currency", 'an exchange rate', 'it'] : ["at least one of the {$namesS} currencies", 'exchange rates', 'them'];
     /** @var string $urlEnable */
     $urlEnable = df_url_backend('admin/system_config/edit/section/currency');
     /** @var string $urlRate */
     $urlRate = df_url_backend('admin/system_currency');
     // 2016-11-20
     // @todo It should return a Phrase, not a string.
     return "Please <a href='{$urlEnable}' target='_blank'>enable</a> {$whatToEnable}" . " and <a href='{$urlRate}' target='_blank'>set {$whatToSet}</a> for {$object}.";
 }
Exemple #3
0
 /**
  * 2016-09-06
  * Название платёжной валюты.
  * @param Currency|string|null $oc [optional]
  * @param null|string|int|S|Store $s [optional]
  * @return string
  */
 public function currencyN($s = null, $oc = null)
 {
     return df_currency_name($this->currency($s, $oc));
 }