Repository URL to install this package:
|
Version:
2.0.2 ▾
|
<?php
namespace Drupal\custom_forms_payment;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
/**
* Provides a listing of custom_forms_payment_methods.
*/
class CustomFormsPaymentMethodListBuilder extends ConfigEntityListBuilder {
/**
* The custom forms payment method manager.
*
* @var \Drupal\custom_forms_payment\CustomFormsPaymentMethodManager $paymentMethodManager
*/
protected $paymentMethodManager;
/**
* @inheritDoc
*/
public function __construct(\Drupal\Core\Entity\EntityTypeInterface $entity_type, \Drupal\Core\Entity\EntityStorageInterface $storage) {
parent::__construct($entity_type, $storage);
$this->paymentMethodManager = \Drupal::service('plugin.manager.custom_forms_payment_methods');
}
/**
* {@inheritdoc}
*/
public function buildHeader() {
$header['label'] = $this->t('Label');
$header['type'] = $this->t('Type');
$header['id'] = $this->t('Machine name');
$header['status'] = $this->t('Status');
return $header + parent::buildHeader();
}
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
$payment = $this->paymentMethodManager->getDefinition($entity->get('plugin'));
/** @var \Drupal\custom_forms_payment\CustomFormsPaymentMethodInterface $entity */
$row['label'] = $entity->label();
$row['type'] = $payment['label'];
$row['id'] = $entity->id();
$row['status'] = $entity->status() ? $this->t('Enabled') : $this->t('Disabled');
return $row + parent::buildRow($entity);
}
}