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

namespace Kufer\web\KuferTools\Teilnehmer\Visitenkarten\VisitenkartenDetails\VisitenkartenDetailsSpeichern;

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

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

  protected function getControllerToForward($pUseCaseResponse)
  {
    return new VisitenkartenDetailsNachSpeichernController($pUseCaseResponse->statusCode);
  }

  protected function getRequestObj()
  {
    $requestObj = new VisitenkartenDetailsSpeichernRequest();
    $requestObj->visitenkarteId = \GetOperations::getVarValue('karteID');

    $wssHandler = new \Kufer\Web\KuferTools\Utils\WssHandler(
      VisitenkartenDetailsSpeichernUseCase::getToolId(),
      VisitenkartenDetailsSpeichernUseCase::getToolSectionId(),
      VisitenkartenDetailsSpeichernUseCase::getUser()
    );
    $requestObj->columnValues = $wssHandler->getColumnValuesFromPost();

    $requestObj->wssHandler = $wssHandler;

    $action = $this->getActionVal();

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