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

class ComboboxNation extends Combobox
{
  protected function getDatamodulAry(): array
  {
    $laender = \ConstantOperations::getLaenderAry();

    $tmpary = array();
    foreach ($laender as $land) {
      $tmpary[] = $this->getDatamodul($land, $land);
    }

    return $tmpary;
  }

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

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

  protected function getDefaultOption(): ?\ComboboxOption
  {
    $option = new ComboboxOption();
    $option->value = '';
    $option->text = 'Land ausw&auml;hlen...';
    $option->isSelected = is_null($this->selectedValue);

    return $option;
  }

  private function getDatamodul($land, $text)
  {
    $datamodul = new \Datamodul();
    $datamodul->land = $land;
    $datamodul->text = $text;

    return $datamodul;
  }
}