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


PHP EntityInterface::getCurrencyCode方法代码示例

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


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

示例1: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $currency, $operation, AccountInterface $account)
 {
     /** @var \Drupal\currency\Entity\CurrencyInterface $currency */
     // Don't let the default currency be deleted.
     if ($currency->getCurrencyCode() == 'XXX' && $operation == 'delete') {
         return AccessResult::forbidden();
     }
     // The "enable" and "disable" operations are aliases for "update", but with
     // extra checks.
     if ($operation == 'enable') {
         return $currency->status() ? AccessResult::forbidden() : $this->access($currency, 'update', $account, TRUE);
     }
     if ($operation == 'disable') {
         return $currency->status() ? $this->access($currency, 'update', $account, TRUE) : AccessResult::forbidden();
     }
     return AccessResult::allowedIfHasPermission($account, 'currency.currency.' . $operation);
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:20,代码来源:CurrencyAccessControlHandler.php

示例2: buildRow

 /**
  * {@inheritdnoc}
  */
 public function buildRow(EntityInterface $payment)
 {
     /** @var \Drupal\payment\Entity\PaymentInterface $payment */
     $row['data']['updated'] = $this->dateFormatter->format($payment->getChangedTime());
     $status_definition = $payment->getPaymentStatus()->getPluginDefinition();
     $row['data']['status'] = $status_definition['label'];
     /** @var \Drupal\currency\Entity\CurrencyInterface $currency */
     $currency = $this->currencyStorage->load($payment->getCurrencyCode());
     if (!$currency) {
         $currency = $this->currencyStorage->load('XXX');
     }
     $row['data']['amount'] = $currency->formatAmount($payment->getAmount());
     $row['data']['payment_method'] = $payment->getPaymentMethod() ? $payment->getPaymentMethod()->getPluginDefinition()['label'] : $this->t('Unavailable');
     $row['data']['owner']['data'] = array('#theme' => 'username', '#account' => $payment->getOwner());
     $operations = $this->buildOperations($payment);
     $row['data']['operations']['data'] = $operations;
     return $row;
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:21,代码来源:PaymentListBuilder.php


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