<?php

declare(strict_types=1);

namespace Drupal\ai;

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

/**
 * Provides a listing of AI Platform configuration entities.
 *
 * @see \Drupal\ai\Entity\AiPlatformConfig
 */
final class AiPlatformListBuilder extends ConfigEntityListBuilder {

  /**
   * {@inheritdoc}
   */
  public function buildHeader(): array {
    $header['label'] = $this->t('Name');
    $header['id'] = $this->t('Machine name');
    $header['platform'] = $this->t('Platform plugin');
    return $header + parent::buildHeader();
  }

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity): array {
    /** @var \Drupal\ai\Entity\AiPlatformConfigInterface $entity */
    $row['label'] = $entity->label();
    $row['id'] = $entity->id();
    $row['platform'] = $entity->getPlatformName();

    return $row + parent::buildRow($entity);
  }

}
