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


PHP Currency::getById方法代码示例

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


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

示例1: resolveValueForImport

 /**
  * There is a special way you can import rateToBase and currencyCode for an amount attribute.
  * if the column data is formatted like: $54.67__1.2__USD  then it will split the column and properly
  * handle rate and currency code.  Eventually this will be exposed in the user interface
  *
  * @param mixed $value
  * @param string $columnName
  * @param array $columnMappingData
  * @param ImportSanitizeResultsUtil $importSanitizeResultsUtil
  * @return array
  */
 public function resolveValueForImport($value, $columnName, $columnMappingData, ImportSanitizeResultsUtil $importSanitizeResultsUtil)
 {
     assert('is_string($columnName)');
     $attributeNames = $this->getRealModelAttributeNames();
     $modelClassName = $this->getModelClassName();
     $parts = explode(FormModelUtil::DELIMITER, $value);
     if (count($parts) == 3) {
         $value = $parts[0];
         $rateToBase = $parts[1];
         try {
             $currency = Currency::getByCode($parts[2]);
         } catch (NotFoundException $e) {
             $currency = null;
             $importSanitizeResultsUtil->addMessage('Currency Code: ' . $parts[2] . ' is invalid.');
             $importSanitizeResultsUtil->setModelShouldNotBeSaved();
         }
     } else {
         $rateToBase = $columnMappingData['mappingRulesData']['CurrencyRateToBaseModelAttributeMappingRuleForm']['rateToBase'];
         $currency = Currency::getById((int) $columnMappingData['mappingRulesData']['CurrencyIdModelAttributeMappingRuleForm']['id']);
     }
     $sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes(static::getSanitizerUtilTypesInProcessingOrder(), $modelClassName, $this->getModelAttributeName(), $value, $columnName, $columnMappingData, $importSanitizeResultsUtil);
     if ($sanitizedValue == null) {
         $sanitizedValue = 0;
     }
     $currencyValue = new CurrencyValue();
     $currencyValue->setScenario('importModel');
     $currencyValue->value = $sanitizedValue;
     $currencyValue->rateToBase = $rateToBase;
     $currencyValue->currency = $currency;
     return array($this->getModelAttributeName() => $currencyValue);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:42,代码来源:CurrencyValueAttributeImportRules.php

示例2: sanitizeValue

 public function sanitizeValue($value)
 {
     $resolvedAcceptableValues = ArrayUtil::resolveArrayToLowerCase(static::getAcceptableValues());
     if ($value != null) {
         if (!in_array(strtolower($value), $resolvedAcceptableValues)) {
             return null;
         }
         $currency = Currency::getByCode($value);
         if ($currency != null) {
             return $currency;
         }
     }
     if (isset($this->mappingRuleData['defaultValue']) && $this->mappingRuleData['defaultValue'] != null) {
         $currency = Currency::getById(intval($this->mappingRuleData['defaultValue']));
         if ($currency != null) {
             return $currency;
         }
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:19,代码来源:UserCurrencySanitizerUtil.php

示例3: resolveValueAndSetToModel

 /**
  * Utilized to create or update model attribute values after a workflow's triggers are fired as true.
  * @param WorkflowActionProcessingModelAdapter $adapter
  * @param $attribute
  * @throws NotSupportedException
  */
 public function resolveValueAndSetToModel(WorkflowActionProcessingModelAdapter $adapter, $attribute)
 {
     assert('is_string($attribute)');
     if ($this->type == static::TYPE_STATIC) {
         $adapter->getModel()->{$attribute}->value = $this->value;
         $adapter->getModel()->{$attribute}->currency = Currency::getById((int) $this->currencyId);
     } else {
         throw new NotSupportedException();
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:16,代码来源:CurrencyValueWorkflowActionAttributeForm.php

示例4: setCurrency__Id

 /**
  * @param $currency__id
  * @throws \Exception
  */
 public function setCurrency__Id($currency__id)
 {
     $currency = null;
     if (is_int($currency__id)) {
         $currency = Currency::getById($currency__id);
         if (!$currency instanceof Currency) {
             throw new \Exception("Currency with ID '{$currency__id}' not found");
         }
     }
     $this->currency__id = $currency__id;
     $this->currency = $currency;
 }
开发者ID:Cube-Solutions,项目名称:pimcore-coreshop,代码行数:16,代码来源:Country.php


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