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


namespace Kufer\KuferTools\Basis\TeilnehmerInfo\UpdateTeilnehmer\HandleTeilnehmerUpdate;

abstract class HandleTeilnehmerUpdateController extends \Kufer\KuferTools\Basis\Controller\ToolController
{
  protected function getRequestObj()
  {
    $requestObj = new HandleTeilnehmerUpdateRequest();
    $requestObj->tnr = \GetOperations::getVarValue('tnr', -1);
    $requestObj->tguid = \GetOperations::getVarValue('tguid', null);
    $wssHandler = new \Kufer\KuferTools\Utils\WssHandler($this->getToolSectionId(), $this->getUser());
    $requestObj->columnValues = $wssHandler->getColumnValuesFromPost();
    $requestObj->wssHandler = $wssHandler;

    $action = $this->getActionVal();

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

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

  abstract protected function getToolId();

  abstract protected function getToolSectionId();

  abstract protected function getUser();

  protected function getControllerToForward($pUseCaseResponse)
  {
    if ($pUseCaseResponse->tnr == -1) {
      header('Location: index.php?tool_id=' . $this->getToolId());
    } else {
      header('Location: index.php?tool_id=' . $this->getToolId() . '&action=teilnehmerdetails&tnr=' . $pUseCaseResponse->tnr . (!is_null($pUseCaseResponse->tguid ?? null) ? '&tguid=' . (string)$pUseCaseResponse->tguid : ''));
    }

    return null;
  }
}