<?php

declare(strict_types=1);

namespace Drupal\{{ machine_name }};

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

/**
 * Defines a class to build a listing of {{ entity_type_label|lower }} type entities.
 *
 * @see \Drupal\{{ machine_name }}\Entity\{{ class }}Type
 */
final class {{ class }}TypeListBuilder extends ConfigEntityListBuilder {

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

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity): array {
    $row['label'] = $entity->label();
    return $row + parent::buildRow($entity);
  }

  /**
   * {@inheritdoc}
   */
  public function render(): array {
    $build = parent::render();

    $build['table']['#empty'] = $this->t(
      'No {{ entity_type_label|lower }} types available. <a href=":link">Add {{ entity_type_label|lower }} type</a>.',
      [':link' => Url::fromRoute('entity.{{ entity_type_id }}_type.add_form')->toString()],
    );

    return $build;
  }

}
