<?php

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
use Slim\Views\Twig;
use Slim\Views\TwigMiddleware;

include "../brain/controller/RouteControl.inc.php";
include "../brain/data/Settings.inc.php";
include "../brain/data/Session.inc.php";
include "../brain/data/Member.inc.php";
include "../brain/data/Auth.inc.php";
include "../brain/data/Render.inc.php";
include "../brain/utility/StringTools.inc.php";
include "../brain/utility/FileUploader.inc.php";
include "../brain/utility/DocTools.inc.php";
include "../brain/utility/Sorting.inc.php";
include "../brain/utility/Setup.inc.php";
include "../brain/utility/Maintenance.inc.php";
include "../brain/utility/Mailer.inc.php";

class App
{
  public function __construct()
  {
    $app = AppFactory::create();
    $twig = Twig::create("../brain/views/");
    $app->add(TwigMiddleware::create($app, $twig));
    //set up routing
    $app->get(
      "/[{first}[/{second}[/{third}[/{fourth}]]]]",
      "\RouteControl:get"
    );
    $app->post(
      "/[{first}[/{second}[/{third}[/{fourth}]]]]",
      "\RouteControl:post"
    );
    //start the app

    $app->run();
  }
}