<?php
/**
 * @copyright (c) Kufer Software GmbH, Oderstraße 7, D-84453 Mühldorf
 */

class ComboboxKursTyp extends Combobox
{
  protected function getDatamodulAry(): array
  {
    $result = array();

    $herrObj = new class() extends Datamodul {
      public $id;
      public $kurz;
      public $lang;
    };
    $herrObj->id = 1;
    $herrObj->kurz = '';
    $herrObj->lang = 'Normalkurs';

    $frauObj = new class() extends Datamodul {
      public $id;
      public $kurz;
      public $lang;
    };
    $frauObj->id = 2;
    $frauObj->kurz = 'E';
    $frauObj->lang = 'Einzelveranstaltung';

    array_push($result, $herrObj, $frauObj);

    return $result;
  }

  protected function getValueFieldName(): string
  {
    return 'kurz';
  }

  protected function getTextFieldName(): string
  {
    return 'lang';
  }

  protected function getDefaultOption(): ?\ComboboxOption
  {
    $option = new ComboboxOption();
    $option->value = '-1';
    $option->text = 'Kurstyp auswählen';
    $option->isSelected = is_null($this->selectedValue) || $this->selectedValue === $option->value;

    return $option;
  }

  protected function isSelected(\ComboboxOption $option): bool
  {
    
    return $option->value === $this->selectedValue;
  }
}