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

namespace Kufer\Web\KuferTools\Basis\Controller;

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

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

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

  protected function getUseCase(): \Kufer\Web\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;
      }
    };
  }
}