summaryrefslogtreecommitdiff
path: root/public/create
diff options
context:
space:
mode:
Diffstat (limited to 'public/create')
-rw-r--r--public/create/index.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/public/create/index.php b/public/create/index.php
new file mode 100644
index 0000000..8256ff5
--- /dev/null
+++ b/public/create/index.php
@@ -0,0 +1,37 @@
+<?php
+
+declare(strict_types=1);
+
+use DTS\Todo;
+use DTS\Errors;
+use DTS\Old;
+use DTS\Session;
+use DTS\Template;
+
+use function DTS\Functions\respondAndExit;
+
+require_once(__DIR__.'/../../autoload.php');
+
+$config = require_once(__DIR__.'/../../config.php');
+
+$session = Session::getInstance();
+
+if (filter_input(INPUT_SERVER, 'REQUEST_METHOD') !== 'GET') {
+ respondAndExit(405, 'Method Not Allowed');
+}
+
+$old = $session->get('old', new Old());
+
+$errors = $session->get('errors', new Errors());
+
+$template = new Template($config['path_to_templates']);
+
+$todo = new Todo();
+
+$html = $template->render('create', compact(
+ 'todo',
+ 'errors',
+ 'old'
+));
+
+respondAndExit(200, 'OK', $html);