<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

use Kufer\Web\Classes\Export\ExportCalculation;

class ExportKategorien extends ExportBasisExt
{
  
  public function initiate()
  {
    \ExportBasis::initiate();
    $this->dboperations = new \DBWorkCategories();
  }

  
  public function export()
  {
    $urlparameter = new \URLParameterHauptmenue();
    $this->clearResult();
    for ($i = 0; $i < count($this->exportsets); $i++) {
      $tmp = $this->dboperations->getCategory($this->exportsets[$i]->id);
      if (isset($tmp->id)) {
        array_push($this->exportresults, $tmp);
      }
    }
  }

  protected function getExportCalc(string $prefix): ?ExportCalculation\ExportCalc
  {
    switch ($prefix) {
      case 'kateg_':
        return new ExportCalculation\ExportCalcCategory($this->expCalculation);
      case 'kat_':
        return new ExportCalculation\ExportCalcCategoryURL($this->expCalculation);
    }

    return null;
  }
}