/** * {@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); }
/** * {@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; }