<?php
declare(strict_types=1);

namespace WP_AUX\Entities\AuxCF\Fields\CuratedCollection;

use AuxCF\Entities\Field\Enum\ChoicesFieldLayoutEnum;
use AuxCF\Entities\Field\RadioFieldEntity;
use WP_AUX\Services\AuxCF\BlocksService;

class CuratedCollectionVariationFieldEntity extends RadioFieldEntity
{
  public static string $name = 'curated_collection_variation';
  protected string $label = 'Variation';
  protected mixed $choices = [];
  protected ChoicesFieldLayoutEnum $layout = ChoicesFieldLayoutEnum::Vertical;

  /**
   * Set default variation value
   *
   * Specify a variation as the default by adding "Default: true" to the file
   * header comments of that variation file.
   *
   * @since 1.0.0
   * @todo Move the default variation to the top of the list of choices
   */
  protected function init(): void
  {
    if ($default = BlocksService::getBlockVariationsDefault('aux_curated_collection')) {
      $this->defaultValue = $default;
    };

    $choices = BlocksService::getBlockVariationsChoices('aux_curated_collection');

    $this->setChoices($choices);
  }
}
