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

namespace Kufer\KuferTools\Mitarbeiter\DozentenInfo\SammelEMail;

class SammelEMailView extends \Kufer\KuferTools\Basis\DozentenInfo\SammelEMail\SammelEMailView
{
  public function getTemplatePathRelative()
  {
    return 'mitarbeiter/dozenteninfo/sammelemail.sgt';
  }

  protected function getDefaultDataModulArray()
  {
    return array_map(function($datamodul) {
      $datamodul->emailandozentsendermultiple = $this->viewModel->emailAnDozentSenderMultiple;
      $datamodul->ma = $this->viewModel->ma;

      return $datamodul;
    }, parent::getDefaultDataModulArray());
  }

  protected function getDefaultExportAdaper()
  {
    return new class() extends \ExpBasis {
      public function initiate()
      {
        $this->export = new class() extends \ExportBasis {
          public function getVarValue($varname)
          {
            switch ($this->getVarCategory($varname)) {
              default:
                return parent::getVarValue($varname);
              case 'ma_':
                return $this->expCalculation->getDefaultVarValue($this->getVarName($varname), $this->exportresults[$this->actualset]->ma ?? new \BASysBenutzer());
              case 'email_':
                return $this->expCalculation->getDefaultVarValue($this->getVarName($varname), $this->exportresults[$this->actualset]);
            }
          }
        };
      }
    };
  }
}