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

namespace Kufer\KuferTools\Basis\DozentenInfo\NewDozent\HandleDozentInsert;

abstract class HandleDozentInsertController extends \Kufer\KuferTools\Basis\Controller\ToolController
{
  abstract protected function getToolSectionId();

  abstract protected function getUser();

  protected function getRequestObj()
  {
    $requestObj = new HandleDozentInsertRequest();
    $requestObj->dnr = \GetOperations::getVarValue('dnr', -1);
    $requestObj->dozinsert = \GetOperations::isDefined('dozinsert');

    $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);
  }

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

  
  abstract protected function getDozentenDetailsToolId();

  protected function getControllerToForward($pUseCaseResponse)
  {
    if ($pUseCaseResponse->dnr == -1) {
      header('Location: index.php?tool_id=' . $this->getDozentenDetailsToolId());
    } else {
      header('Location: index.php?tool_id=' . $this->getDozentenDetailsToolId() . '&action=dozentdetails&dnr=' . $pUseCaseResponse->dnr);
    }

    return null;
  }
}