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

namespace Kufer\KuferTools\Dozent\Kursplanung\TerminSammelaenderung;

class TerminSammelaenderungAbsendenController extends \Kufer\KuferTools\Basis\Controller\ToolController
{
  
  protected function getUseCase(): \Kufer\KuferTools\Basis\UseCase\UseCase
  {
    return new TerminSammelaenderungAbsendenUseCase(
      $this->getRequestObj()
    );
  }

  
  protected function getRequestObj()
  {
    $requestObj = new TerminSammelaenderungAbsendenRequest();
    $requestObj->knr = \GetOperations::getVarValue('knr');

    $ktApi = new \KurstagAPI();
    $requestObj->ktIds = explode(':', \GetOperations::getVarValue('ktIds'));
    $requestObj->changedFields = $ktApi->getChangedFieldsFromPost(); 
    $requestObj->change = $ktApi->getChangeObjFromPost();

    $action = $this->getActionVal();

    return $this->handleXsrf($requestObj, $action);
  }

  protected function getControllerToForward($pUseCaseResponse)
  {
    return new \Kufer\KuferTools\Dozent\Kursplanung\TerminUebersicht\TerminUebersichtNachAbsendenController(
      $pUseCaseResponse->knr,
      $pUseCaseResponse->statusCode,
      $pUseCaseResponse->failedToUpdateKtAry
    );
  }

  protected function getPresenter($pUseCaseResponse)
  {
    return null;
  }
}