PaymentGatewayListBuilder.php in Commerce Core 8.2
File
modules/payment/src/PaymentGatewayListBuilder.php
View source
<?php
namespace Drupal\commerce_payment;
use Drupal\Core\Config\Entity\DraggableListBuilder;
use Drupal\Core\Entity\EntityInterface;
class PaymentGatewayListBuilder extends DraggableListBuilder {
protected $entitiesKey = 'gateways';
public function getFormId() {
return 'commerce_payment_gateways';
}
public function buildHeader() {
$header['label'] = $this
->t('Payment gateway');
$header['id'] = $this
->t('ID');
$header['mode'] = $this
->t('Mode');
$header['status'] = $this
->t('Status');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$payment_gateway_plugin = $entity
->getPlugin();
$modes = $payment_gateway_plugin
->getSupportedModes();
$mode = $modes ? $modes[$payment_gateway_plugin
->getMode()] : $this
->t('N/A');
$status = $entity
->status() ? $this
->t('Enabled') : $this
->t('Disabled');
$row['label'] = $entity
->label();
$row['id']['#markup'] = $entity
->id();
if (!empty($this->weightKey)) {
$row['mode']['#markup'] = $mode;
$row['status']['#markup'] = $status;
}
else {
$row['mode'] = $mode;
$row['status'] = $status;
}
return $row + parent::buildRow($entity);
}
public function render() {
$entities = $this
->load();
if (count($entities) <= 1) {
unset($this->weightKey);
}
return parent::render();
}
}