l10n_server-2.x-dev/l10n_server/src/Entity/ListBuilder/L10nServerErrorListBuilder.php

l10n_server/src/Entity/ListBuilder/L10nServerErrorListBuilder.php
<?php

declare(strict_types=1);

namespace Drupal\l10n_server\Entity\ListBuilder;

use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;

/**
 * Provides a list controller for the error entity type.
 */
class L10nServerErrorListBuilder extends EntityListBuilder {

  /**
   * {@inheritdoc}
   */
  public function render(): array {
    $build['table'] = parent::render();
    $total = $this->getStorage()
      ->getQuery()
      ->accessCheck(TRUE)
      ->count()
      ->execute();
    $build['summary']['#markup'] = $this->t('Total errors: @total', [
      '@total' => $total,
    ]);
    return $build;
  }

  /**
   * {@inheritdoc}
   */
  public function buildHeader(): array {
    $header['id'] = $this->t('ID');
    $header['rid'] = $this->t('Release ID');
    $header['value'] = $this->t('Value');
    return $header + parent::buildHeader();
  }

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity): array {
    /** @var \Drupal\l10n_server\Entity\L10nServerErrorInterface $entity */
    $row['id'] = $entity->id();
    $row['rid'] = $entity->getReleaseId();
    $row['value'] = $entity->getValue();
    return $row + parent::buildRow($entity);
  }

}

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

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