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

namespace Kufer\Web\KuferTools\Dozent\SammelVertraege\AkzeptierenOderAblehnen\Absenden;

use Kufer\Web\KuferTools\Dozent\SammelVertraege\AkzeptierenOderAblehnen;

abstract class SammelVertraegeAkzeptierenOderAblehnenAbsendenController extends \Kufer\KuferTools\Basis\Controller\Controller
{
  protected function getRequestObj()
  {
    $request = new SammelVertraegeAkzeptierenOderAblehnenAbsendenRequest();
    $request->id = \GetOperations::getVarValue('id');
    $request->kursIds = \PostOperations::getVarValue('kurs_ids');
    $request->additionalInfo = \PostOperations::getVarValue('additional_info');
    $request->checkread = \PostOperations::isDefined('checkread');
    if (!is_array($request->kursIds)) {
      $request->kursIds = array();
    }

    $action = $this->getActionVal();

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

  protected function getControllerToForward($pUseCaseResponse)
  {
    if ($pUseCaseResponse->formerror) {
      return $this->getFormErrorController($pUseCaseResponse);
    }

    return null;
  }

  abstract protected function getFormErrorController($useCaseResponse): AkzeptierenOderAblehnen\Formular\SammelVertraegeAkzeptierenOderAblehnenController;
}