本文整理汇总了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);
}
示例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;
}