<?php
/**
 * @copyright (c) Kufer Software GmbH, Oderstraße 7, D-84453 Mühldorf
 */

namespace Kufer\Web\KuferTools\Dozent\Portrait\DozentenportraitBearbeiten;

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

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

    $wssHandler = new \Kufer\Web\KuferTools\Utils\WssHandler(
      DozentenPortraitBearbeitenAbsendenUseCase::getToolId(),
      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\Web\KuferTools\Dozent\Portrait\Dozentenportrait\DozentenPortraitNachAbsendenController($pUseCaseResponse->statusCodes, $pUseCaseResponse->wrongFields, $pUseCaseResponse->changedDozentenPortrait);
  }

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