<?php

declare(strict_types=1);

namespace Drupal\{{ machine_name }}\Entity;

{% apply sort_namespaces %}
use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
use Drupal\Core\Entity\Attribute\ConfigEntityType;
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
use Drupal\Core\Entity\EntityDeleteForm;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\{{ machine_name }}\Form\{{ class }}TypeForm;
use Drupal\{{ machine_name }}\{{ class }}TypeListBuilder;
{% endapply %}

/**
 * Defines the {{ entity_type_label }} type configuration entity.
 */
#[ConfigEntityType(
  id: '{{ entity_type_id }}_type',
  label: new TranslatableMarkup('{{ entity_type_label }} type'),
  label_collection: new TranslatableMarkup('{{ entity_type_label }} types'),
  label_singular: new TranslatableMarkup('{{ entity_type_label|lower }} type'),
  label_plural: new TranslatableMarkup('{{ entity_type_label|pluralize|lower }} types'),
  config_prefix: '{{ entity_type_id }}_type',
  entity_keys: [
    'id' => 'id',
    'label' => 'label',
    'uuid' => 'uuid',
  ],
  handlers: [
    'list_builder' => {{ class }}TypeListBuilder::class,
    'route_provider' => [
      'html' => AdminHtmlRouteProvider::class,
    ],
    'form' => [
      'add' => {{ class }}TypeForm::class,
      'edit' => {{ class }}TypeForm::class,
      'delete' => EntityDeleteForm::class,
    ],
  ],
  links: [
    'add-form' => '/admin/structure/{{ entity_type_id }}_types/add',
    'edit-form' => '/admin/structure/{{ entity_type_id }}_types/manage/{{ '{' ~ entity_type_id ~ '_type}' }}',
    'delete-form' => '/admin/structure/{{ entity_type_id }}_types/manage/{{ '{' ~ entity_type_id ~ '_type}' }}/delete',
    'collection' => '/admin/structure/{{ entity_type_id }}_types',
  ],
  admin_permission: '{{ permissions.administer }}',
  bundle_of: '{{ entity_type_id }}',
  label_count: [
    'singular' => '@count {{ entity_type_label|lower }} type',
    'plural' => '@count {{ entity_type_label|pluralize|lower }} types',
  ],
  config_export: [
    'id',
    'label',
    'uuid',
  ],
)]
final class {{ class }}Type extends ConfigEntityBundleBase {

  /**
   * The machine name of this {{ entity_type_label|lower }} type.
   */
  protected string $id;

  /**
   * The human-readable name of the {{ entity_type_label|lower }} type.
   */
  protected string $label;

}
