smsplatform-1.0.x-dev/src/Lists/SmsGatewayListBuilder.php

src/Lists/SmsGatewayListBuilder.php
<?php

declare(strict_types=1);

namespace Drupal\smsplatform\Lists;

use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;

/**
 * Builds a list of SMS Gateway plugins.
 */
class SmsGatewayListBuilder extends ConfigEntityListBuilder {

  /**
   * {@inheritdoc}
   */
  public function buildHeader() {
    $header['label'] = $this->t('Label');
    $header['gateway'] = $this->t('Gateway');
    $header['status'] = $this->t('Status');
    return $header + parent::buildHeader();
  }

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {
    /** @var \Drupal\smsplatform\Entity\SmsGatewayInterface $entity */
    $row['label'] = $entity->label();
    $row['gateway'] = $entity->getPlugin()->getPluginDefinition()['label'];
    $row['status'] = $entity->status() ? $this->t('Enabled') : $this->t('Disabled');
    return $row + parent::buildRow($entity);
  }

  /**
   * {@inheritdoc}
   */
  public function render() {
    $render = parent::render();
    $render['table']['#empty'] = $this->t('No gateways available.');
    return $render;
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc