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

namespace Kufer\Web\KuferTools\Allgemein\Ferien;

use Kufer\KuferTools\Basis\Presenter\JsonPresenterStringOnly;
use Kufer\Web\KuferTools\Basis\Controller\SimpleJsonResponseController;

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

  protected function getAccessDeniedController()
  {
    $response = new class() {
      public $success;
      public $error_msg;
    };

    $response->success = false;
    $response->error_msg = 'Nicht eingeloggt';

    return new SimpleJsonResponseController(json_encode(\StringOperations::objectConvertStringEncoding($response, \CodingOperations::getInternalEncoding(), UTF_8)));
  }

  protected function getNotLoggedController()
  {
    return $this->getAccessDeniedController();
  }

  protected function getRequestObj()
  {
    $result = new FerienRequest();
    $result->kalenderId = \GetOperations::getVarValue('kalender_id', null);

    return $result;
  }

  protected function getPresenter($pUseCaseResponse)
  {
    return new FerienPresenter($pUseCaseResponse);
  }
}