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

namespace Kufer\Web\KuferTools\Teilnehmer\Visitenkarten\NeueVisitenkarteErstellen\NeueVisitenkarteErstellenSpeichern;

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

  protected function getToolId()
  {
    return InsertVisitenkarteUseCase::getToolId();
  }

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

  protected function getControllerToForward($pUseCaseResponse)
  {
    return new NachInsertVisitenkarteController($pUseCaseResponse->statusCode, $pUseCaseResponse->visitenkarteId);
  }

  protected function getRequestObj()
  {
    $requestObj = new InsertVisitenkarteUebersichtRequest();
    $tooSectionId = InsertVisitenkarteUseCase::getToolSectionId();
    $user = InsertVisitenkarteUseCase::getUser();

    $wssHandler = new \Kufer\KuferTools\Utils\WssHandler($tooSectionId, $user);

    $requestObj->columnValues = $wssHandler->getColumnValuesFromPost();
    $requestObj->wssHandler = $wssHandler;

    $action = $this->getActionVal();

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