protected function PaymentReferenceBase::buildPaymentView in Payment 8.2
Builds the payment view.
Parameters
mixed[] $element: The root element.
\Drupal\Core\Form\FormStateInterface $form_state:
Return value
array A render array.
1 call to PaymentReferenceBase::buildPaymentView()
- PaymentReferenceBase::process in src/
Element/ PaymentReferenceBase.php - Implements form #process callback.
File
- src/
Element/ PaymentReferenceBase.php, line 368
Class
- PaymentReferenceBase
- Provides a base for payment reference elements.
Namespace
Drupal\payment\ElementCode
protected function buildPaymentView(array $element, FormStateInterface $form_state) {
$payment_id = $element['#default_value'] ?: $element['#available_payment_id'];
/** @var \Drupal\payment\Entity\PaymentInterface|null $payment */
$payment = $payment_id ? $this->paymentStorage
->load($payment_id) : NULL;
$build = [];
if ($payment) {
$currency = $payment
->getCurrency();
$status = $payment
->getPaymentStatus();
$status_definition = $status
->getPluginDefinition();
$build = array(
'#empty' => $this
->t('There are no line items.'),
'#header' => array(
$this
->t('Amount'),
$this
->t('Status'),
$this
->t('Last updated'),
),
'#type' => 'table',
);
$build[0]['amount'] = array(
'#markup' => $currency
->formatAmount($payment
->getAmount()),
);
$build[0]['status'] = array(
'#markup' => $status_definition['label'],
);
$build[0]['updated'] = array(
'#markup' => $this->dateFormatter
->format($status
->getCreated()),
);
if ($payment
->access('view')) {
$build['#header'][] = $this
->t('Operations');
$build[0]['view'] = array(
'#markup' => $this
->t('<a href="@url" target="_blank">View payment details</a> (opens in a new window)', array(
'@url' => $payment
->toUrl()
->toString(),
)),
);
}
}
return $build;
}