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

namespace Kufer\Web\KuferTools\Basis\Controller;

use Kufer\KuferTools\Basis\Presenter\Presenter;
use Kufer\KuferTools\Basis\UseCase\DummyUseCase;
use Kufer\KuferTools\Basis\View\View;

final class SimpleJsonResponseController extends \Kufer\KuferTools\Basis\Controller\AjaxNoContainerToolController
{
  
  private $response;

  public function __construct(string $response)
  {
    $this->response = $response;
  }

  protected function getUseCase(): \Kufer\KuferTools\Basis\UseCase\UseCase
  {
    return new DummyUseCase($this->getRequestObj());
  }

  protected function getRequestObj()
  {
    return new class() {
    };
  }

  protected function getAccessDeniedController()
  {
    return null;
  }

  protected function getNotLoggedController()
  {
    return null;
  }

  protected function getPresenter($pUseCaseResponse)
  {
    return new class($this->response) extends Presenter {
      private $response;

      public function __construct(string $response)
      {
        parent::__construct(new \stdClass());
        $this->response = $response;
      }

      protected function getView()
      {
        return new class($this->response) extends View {
          private $response;

          public function __construct(string $response)
          {
            parent::__construct(new \stdClass());
            $this->response = $response;
          }

          public function show()
          {
            return $this->response;
          }
        };
      }

      protected function getViewModel()
      {
        return new class() {
        };
      }

      public function setRequestHeader()
      {
        header('Content-Type: application/json; encoding=utf-8');
      }

      public function getEncoding()
      {
        return UTF_8;
      }

      public function getExternalEncoding()
      {
        return UTF_8;
      }
    };
  }
}