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

namespace Kufer\KuferTools\Teilnehmer\KursUebersicht\Ics;

class IcsKalenderController extends \Kufer\KuferTools\Basis\Ics\IcsKalenderController
{
  
  protected function getUseCase(): \Kufer\KuferTools\Basis\UseCase\UseCase
  {
    return new IcsKalenderUseCase(
      $this->getRequestObj()
    );
  }

  
  protected function getRequestObj()
  {
    $von = \PostOperations::getVarValue('terminvon', '');
    $bis = \PostOperations::getVarValue('terminbis', '');
    $vondat = (!empty($von) ? $von : \GetOperations::getVarValue('von', ''));
    $bisdat = (!empty($bis) ? $bis : \GetOperations::getVarValue('bis', ''));

    $requestObj = parent::getRequestObj();
    $requestObj->vondat = \DateTimeOperations::getValidDateString($vondat);
    $requestObj->bisdat = \DateTimeOperations::getValidDateString($bisdat);
    $requestObj->terminnummern = \GetOperations::getVarValue('terminnr');
    $belNummern = \GetOperations::getVarValue('belnummern', '');
    if (empty($belNummern)) {
      $requestObj->belnummern = array();
    } else {
      $requestObj->belnummern = \explode(':', $belNummern);
    }

    return $requestObj;
  }
}