You are here

public function AutobanListBuilder::buildRow in Automatic IP ban (Autoban) 8

Builds a row for an entity in the entity listing.

Parameters

Drupal\Core\Entity\EntityInterface $entity: The entity for which to build the row.

Return value

array A render array of the table row for displaying the entity.

Overrides EntityListBuilder::buildRow

See also

Drupal\Core\Entity\EntityListController::render()

File

src/Controller/AutobanListBuilder.php, line 114

Class

AutobanListBuilder
Provides a listing of autoban entities.

Namespace

Drupal\autoban\Controller

Code

public function buildRow(EntityInterface $entity) {
  $row['id'] = $entity
    ->id();
  $row['type'] = $entity->type;
  $row['message'] = $entity->message;
  $row['referer'] = $entity->referer;
  $row['threshold'] = $entity->threshold;
  $controller = $this->autoban;
  $row['user_type'] = $controller
    ->userTypeList($entity->user_type ?: 0);
  if (!$this->banProviderList) {
    $this->banProviderList = $this
      ->getBanProvidersList();
  }
  if (!empty($this->banProviderList) && isset($this->banProviderList[$entity->provider])) {
    $row['provider'] = $this->banProviderList[$entity->provider];
  }
  else {

    // If ban provider module is disabled.
    $row['provider'] = $this
      ->t('Inactive provider %provider', [
      '%provider' => $entity->provider,
    ]);
  }
  return $row + parent::buildRow($entity);
}