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

namespace Kufer\Web\KuferTools\Teilnehmer\KursUebersicht\Ics;

class IcsKalenderController extends \Kufer\Web\KuferTools\Basis\Ics\IcsKalenderController
{
  
  protected function getUseCase(): \Kufer\Web\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;
  }
}