You are here

function DatexPartialImplementation::listOptions in Datex 8

Overrides DatexInterface::listOptions

File

src/Datex/DatexPartialImplementation.php, line 26

Class

DatexPartialImplementation

Namespace

Drupal\datex\Datex

Code

function listOptions($name, $required) {
  $none = [
    '' => '',
  ];
  $year = $this
    ->getBaseYear();
  switch ($name) {
    case 'monthNames':
      $m = [];
      for ($i = 1; $i < 13; $i++) {
        $this
          ->setDateLocale($year, $i, 1);
        $m[$i] = $this
          ->format('F');
      }
      return !$required ? $none + $m : $m;
    case 'monthNamesAbbr':
      $m = [];
      for ($i = 1; $i < 13; $i++) {
        $this
          ->setDateLocale($year, $i, 1);
        $m[$i] = $this
          ->format('M');
      }
      return !$required ? $none + $m : $m;
  }
  return $none;
}