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

namespace Kufer\KuferTools\Dozent\Portrait\DozentenportraitBearbeiten;

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

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

    $wssHandler = new \Kufer\KuferTools\Utils\WssHandler(DozentenPortraitBearbeitenAbsendenUseCase::getToolSectionId(), DozentenPortraitBearbeitenAbsendenUseCase::getUser());
    $requestObj->columnValues = $wssHandler->getColumnValuesFromPost();
    $requestObj->wssHandler = $wssHandler;
    $requestObj->portrait_loeschen = \RequestOperations::getVarValue('portrait_loeschen') === 'ja';
    $requestObj->portrait_in_bearbeitung_loeschen = \RequestOperations::getVarValue('portrait_in_bearbeitung_loeschen') === 'ja';

    $action = $this->getActionVal();

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

  protected function getControllerToForward($pUseCaseResponse)
  {
    return new \Kufer\KuferTools\Dozent\Portrait\Dozentenportrait\DozentenPortraitNachAbsendenController($pUseCaseResponse->statusCodes, $pUseCaseResponse->wrongFields, $pUseCaseResponse->changedDozentenPortrait);
  }

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