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

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

class InsertVisitenkarteController extends \Kufer\Web\KuferTools\Basis\Controller\ToolController
{
  protected function getUseCase(): \Kufer\Web\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\Web\KuferTools\Utils\WssHandler(
      InsertVisitenkarteUseCase::getToolId(),
      $tooSectionId,
      $user
    );

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

    $action = $this->getActionVal();

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