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

namespace Kufer\Web\KuferTools\Basis\Kursdetails\DetailsReiter\Teilnehmer\SammelEinzelBearbeitung;

use Kufer\KuferTools\Utils\WssHandler;

abstract class HandleSammelEinzelBearbeitungController extends \Kufer\KuferTools\Basis\Controller\Controller
{
  protected function getNewRequestObj(): HandleSammelEinzelBearbeitungRequest
  {
    return new HandleSammelEinzelBearbeitungRequest();
  }

  protected function getRequestObj()
  {
    $result = $this->getNewRequestObj();
    $result->knr = \GetOperations::getVarValue('knr');
    $result->belids = \PostOperations::getVarValue('belids', array());

    $wssHandler = new WssHandler($this->getFormToolSectionId(), HandleSammelEinzelBearbeitungUseCase::getUser());
    $result->columnValuesMap = array();
    foreach ($result->belids as $belid) {
      $result->columnValuesMap[$belid] = $wssHandler->getColumnValuesFromPost('form' . $belid);
    }
    $result->wssHandler = $wssHandler;
    $action = $this->getActionVal();

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

  abstract protected function getToolId(): int;

  abstract protected function getFormToolSectionId();

  protected function getPresenter($pUseCaseResponse)
  {
    return new SammelEinzelBearbeitungFormularPresenter($pUseCaseResponse, false);
  }
}