当前位置: 首页>>代码示例>>PHP>>正文


PHP Intl::getCurrencyBundle方法代码示例

本文整理汇总了PHP中Symfony\Component\Intl\Intl::getCurrencyBundle方法的典型用法代码示例。如果您正苦于以下问题:PHP Intl::getCurrencyBundle方法的具体用法?PHP Intl::getCurrencyBundle怎么用?PHP Intl::getCurrencyBundle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Intl\Intl的用法示例。


在下文中一共展示了Intl::getCurrencyBundle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: guard

 /**
  * @param string $value
  *
  * @throws InvalidCurrencyException
  */
 protected function guard($value)
 {
     $currency = Intl::getCurrencyBundle()->getCurrencyName($value);
     if (null === $currency) {
         throw new InvalidCurrencyException($value);
     }
 }
开发者ID:bruli,项目名称:php-value-objects,代码行数:12,代码来源:Currency.php

示例2: loadChoiceList

 /**
  * {@inheritdoc}
  */
 public function loadChoiceList($value = null)
 {
     if (null !== $this->choiceList) {
         return $this->choiceList;
     }
     return $this->choiceList = new ArrayChoiceList(array_flip(Intl::getCurrencyBundle()->getCurrencyNames()), $value);
 }
开发者ID:ayoah,项目名称:symfony,代码行数:10,代码来源:CurrencyType.php

示例3: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(array(
         'choices' => Intl::getCurrencyBundle()->getCurrencyNames(),
         'choice_translation_domain' => false,
     ));
 }
开发者ID:ninvfeng,项目名称:symfony,代码行数:10,代码来源:CurrencyType.php

示例4: validate

    /**
     * {@inheritdoc}
     */
    public function validate($value, Constraint $constraint)
    {
        if (!$constraint instanceof Currency) {
            throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Currency');
        }

        if (null === $value || '' === $value) {
            return;
        }

        if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
            throw new UnexpectedTypeException($value, 'string');
        }

        $value = (string) $value;
        $currencies = Intl::getCurrencyBundle()->getCurrencyNames();

        if (!isset($currencies[$value])) {
            if ($this->context instanceof ExecutionContextInterface) {
                $this->context->buildViolation($constraint->message)
                    ->setParameter('{{ value }}', $this->formatValue($value))
                    ->setCode(Currency::NO_SUCH_CURRENCY_ERROR)
                    ->addViolation();
            } else {
                $this->buildViolation($constraint->message)
                    ->setParameter('{{ value }}', $this->formatValue($value))
                    ->setCode(Currency::NO_SUCH_CURRENCY_ERROR)
                    ->addViolation();
            }
        }
    }
开发者ID:ninvfeng,项目名称:symfony,代码行数:34,代码来源:CurrencyValidator.php

示例5: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $textWriter = new TextBundleWriter();
     $textWriter->write(CACHE_PATH . 'intl/text_bundle', 'en', ['data' => ['Ok']]);
     $textWriter->write(CACHE_PATH . 'intl/text_bundle', 'ru', ['data' => ['Хорошо']]);
     $phpWriter = new PhpBundleWriter();
     $phpWriter->write(CACHE_PATH . 'intl/php_bundle', 'en', ['data' => 'php bundle: Ok', 'nested' => ['message' => 'Hi!']]);
     $phpWriter = new PhpBundleWriter();
     $phpWriter->write(CACHE_PATH . 'intl/php_bundle', 'ru', ['data' => 'php bundle: Хорошо', 'nested' => ['message' => 'Привет!']]);
     $compiler = new GenrbCompiler();
     $compiler->compile(CACHE_PATH . 'intl/text_bundle', CACHE_PATH . 'intl/compiled');
     $phpReader = new PhpBundleReader();
     $data = $phpReader->read(CACHE_PATH . 'intl/php_bundle', 'en');
     $output->writeln($data['data']);
     $data = $phpReader->read(CACHE_PATH . 'intl/php_bundle', 'ru');
     $output->writeln($data['data']);
     $reader = new BundleEntryReader($phpReader);
     $data = $reader->readEntry(CACHE_PATH . 'intl/php_bundle', 'ru', ['nested', 'message']);
     $output->writeln($data);
     $language = Intl::getLanguageBundle()->getLanguageName('ru', 'RU', 'en');
     $output->writeln($language);
     $language = Intl::getLanguageBundle()->getLanguageName('ru', 'RU', 'de');
     $output->writeln($language);
     $language = Intl::getLanguageBundle()->getLanguageName('ru', 'RU', 'ru');
     $output->writeln($language);
     $currencyName = Intl::getCurrencyBundle()->getCurrencyName('RUB', 'en');
     $output->writeln($currencyName);
     $currencyName = Intl::getCurrencyBundle()->getCurrencySymbol('USD', 'en');
     $output->writeln($currencyName);
     $output->writeln('<comment>Ok</comment>');
 }
开发者ID:GrizliK1988,项目名称:symfony-certification-prepare-project,代码行数:31,代码来源:IntlTestCommand.php

示例6: getSettings

 /**
  * @return array
  */
 public function getSettings()
 {
     $settings = $this->getYamlParameters();
     $currency = new Setting();
     $currency->setKey('currency')->setValue($settings['currency'])->setType('select2')->setOptions(Intl::getCurrencyBundle()->getCurrencyNames($settings['locale']));
     $emailSettings = $this->getEmailSettings($settings);
     return ['system' => ['general' => ['currency' => $currency]], 'email' => ['sending_options' => $emailSettings]];
 }
开发者ID:csbill,项目名称:csbill,代码行数:11,代码来源:SettingsLoader.php

示例7: getCurrencySymbol

 public function getCurrencySymbol($currency = null)
 {
     $currency = $currency ?: $this->helper->getSettingsParameter($this->generalCurrencyKey);
     if (array_key_exists($currency, $this->currencySymbols)) {
         return $this->currencySymbols[$currency];
     }
     return SymfonyIntl::getCurrencyBundle()->getCurrencySymbol($currency);
 }
开发者ID:liverbool,项目名称:dos-resource-bundle,代码行数:8,代码来源:Currency.php

示例8: __construct

 /**
  * @param float  $value   value
  * @param string $currency currency
  */
 public function __construct($value, $currency = 'EUR', $formatter = null)
 {
     $this->value = (double) $value;
     $this->currency = strtoupper((string) $currency);
     $this->fractionDigits = Intl::getCurrencyBundle()->getFractionDigits($currency);
     if ($formatter) {
         $this->setFormatter($formatter);
     }
 }
开发者ID:rezzza,项目名称:accounting,代码行数:13,代码来源:Price.php

示例9: testValidChoiceList

 public function testValidChoiceList()
 {
     $form = $this->factory->create(CurrencyType::class);
     $validList = array_keys(Intl::getCurrencyBundle()->getCurrencyNames('en'));
     sort($validList);
     $choices = $form->getConfig()->getOption('choices');
     sort($choices);
     $this->assertSame($validList, $choices);
 }
开发者ID:mcdir,项目名称:SonatraFormExtensionsBundle,代码行数:9,代码来源:CurrencyTypeTest.php

示例10: convertToCode

 /**
  * {@inheritdoc}
  */
 public function convertToCode($name, $locale = 'en')
 {
     $names = Intl::getCurrencyBundle()->getCurrencyNames($locale);
     $currencyCode = array_search($name, $names, true);
     if (false === $currencyCode) {
         throw new \InvalidArgumentException(sprintf('Currency "%s" not found! Available names: %s.', $name, implode(', ', $names)));
     }
     return $currencyCode;
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:12,代码来源:CurrencyNameConverter.php

示例11: convertToPHPValue

 /**
  * {@inheritdoc}
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if (!array_key_exists($value, Intl::getCurrencyBundle()->getCurrencyNames())) {
         throw new \RuntimeException(sprintf("'%d' is not a supported currency.", $value));
     }
     $currency = new Currency();
     $currency->setLabel($value);
     return $currency;
 }
开发者ID:sonata-project,项目名称:ecommerce,代码行数:12,代码来源:CurrencyDoctrineType.php

示例12: beforeCreateStub

 /**
  * {@inheritdoc}
  */
 public function beforeCreateStub(StubbingContextInterface $context)
 {
     $currencies = array();
     $currencyBundle = Intl::getCurrencyBundle();
     foreach ($currencyBundle->getCurrencyNames('en') as $code => $name) {
         $currencies[$code] = array(CurrencyBundle::INDEX_NAME => $name, CurrencyBundle::INDEX_SYMBOL => $currencyBundle->getCurrencySymbol($code, 'en'), CurrencyBundle::INDEX_FRACTION_DIGITS => $currencyBundle->getFractionDigits($code), CurrencyBundle::INDEX_ROUNDING_INCREMENT => $currencyBundle->getRoundingIncrement($code));
     }
     return array('Currencies' => $currencies);
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:12,代码来源:CurrencyBundleTransformationRule.php

示例13: installCurrencies

 /**
  * Installs the given currencies by codes.
  *
  * @param array $codes
  *
  * @throws \Exception
  */
 public function installCurrencies($codes = array('USD'))
 {
     if (empty($codes)) {
         throw new \Exception("Expected non empty array of currency codes.");
     }
     $currencyNames = Intl::getCurrencyBundle()->getCurrencyNames();
     // TODO locale + sort by name
     asort($currencyNames);
     $this->generate(Currency::class, $currencyNames, $codes);
 }
开发者ID:ekyna,项目名称:commerce,代码行数:17,代码来源:Installer.php

示例14: prepareCurrencies

 private static function prepareCurrencies($locale)
 {
     self::$currencies = array();
     self::$currenciesNames = array();
     $bundle = Intl::getCurrencyBundle();
     foreach ($bundle->getCurrencyNames($locale) as $currency => $name) {
         self::$currencies[$currency] = array('name' => $name, 'symbol' => $bundle->getCurrencySymbol($currency, $locale), 'fractionDigits' => $bundle->getFractionDigits($currency), 'roundingIncrement' => $bundle->getRoundingIncrement($currency));
         self::$currenciesNames[$currency] = $name;
     }
 }
开发者ID:RuntyCybin,项目名称:csymfony,代码行数:10,代码来源:StubLocale.php

示例15: submitDataProvider

 /**
  * @return array
  */
 public function submitDataProvider()
 {
     $currencyBundle = Intl::getCurrencyBundle();
     $usdName = $currencyBundle->getCurrencyName('USD');
     $eurName = $currencyBundle->getCurrencyName('EUR');
     $gbpName = $currencyBundle->getCurrencyName('GBP');
     $rubName = $currencyBundle->getCurrencyName('RUB');
     $uahName = $currencyBundle->getCurrencyName('UAH');
     return ['full currency name and data from system config' => ['allowedCurrencies' => ['USD', 'UAH'], 'localeCurrency' => 'EUR', 'inputOptions' => [], 'expectedOptions' => ['compact' => false, 'choices' => ['USD' => $usdName, 'UAH' => $uahName]], 'submittedData' => 'UAH'], 'compact currency name and data from system config' => ['allowedCurrencies' => ['USD', 'UAH'], 'localeCurrency' => 'EUR', 'inputOptions' => ['compact' => true], 'expectedOptions' => ['compact' => true, 'choices' => ['USD' => 'USD', 'UAH' => 'UAH']], 'submittedData' => 'UAH'], 'full currency name and data from locale settings' => ['allowedCurrencies' => [], 'localeCurrency' => 'EUR', 'inputOptions' => ['compact' => false, 'currencies_list' => null], 'expectedOptions' => ['compact' => false, 'choices' => ['EUR' => $eurName]], 'submittedData' => 'EUR'], 'full currency name and data from currencies_list option' => ['allowedCurrencies' => ['USD', 'UAH'], 'localeCurrency' => 'EUR', 'inputOptions' => ['compact' => false, 'currencies_list' => ['RUB']], 'expectedOptions' => ['compact' => false, 'choices' => ['RUB' => $rubName]], 'submittedData' => 'RUB'], 'full currency name, data from system config and additional currencies' => ['allowedCurrencies' => ['USD', 'UAH'], 'localeCurrency' => 'EUR', 'inputOptions' => ['additional_currencies' => ['GBP']], 'expectedOptions' => ['compact' => false, 'choices' => ['GBP' => $gbpName, 'USD' => $usdName, 'UAH' => $uahName]], 'submittedData' => 'UAH'], 'compact currency name, data from currencies_list option and additional currencies' => ['allowedCurrencies' => ['USD', 'UAH'], 'localeCurrency' => 'EUR', 'inputOptions' => ['compact' => true, 'currencies_list' => ['RUB'], 'additional_currencies' => ['GBP']], 'expectedOptions' => ['compact' => true, 'choices' => ['GBP' => 'GBP', 'RUB' => 'RUB']], 'submittedData' => 'GBP'], 'full currencies list' => ['allowedCurrencies' => ['USD', 'UAH'], 'localeCurrency' => 'EUR', 'inputOptions' => ['full_currency_list' => true], 'expectedOptions' => ['full_currency_list' => true, 'choices' => $currencyBundle->getCurrencyNames('en')], 'submittedData' => 'GBP']];
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:13,代码来源:CurrencySelectionTypeTest.php


注:本文中的Symfony\Component\Intl\Intl::getCurrencyBundle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。