diff options
Diffstat (limited to 'public/delete/confirm/index.php')
| -rw-r--r-- | public/delete/confirm/index.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/public/delete/confirm/index.php b/public/delete/confirm/index.php new file mode 100644 index 0000000..6636fe9 --- /dev/null +++ b/public/delete/confirm/index.php @@ -0,0 +1,31 @@ +<?php + +declare(strict_types=1); + +use DTS\BookmarkRepository; +use DTS\Template; +use function DTS\Functions\respondAndExit; + +require_once(__DIR__.'/../../../autoload.php'); + +$config = require_once(__DIR__.'/../../../config.php'); + +if (filter_input(INPUT_SERVER, 'REQUEST_METHOD') !== 'GET') { + respondAndExit(405, 'Method Not Allowed'); +} + +$id = filter_input(INPUT_GET, 'id'); + +$bookmarks = new BookmarkRepository($config['path_to_repository']); + +$template = new Template($config['path_to_templates']); + +$bookmark = $bookmarks->find($id); + +if ($bookmark === null) { + respondAndExit(404, 'Not Found'); +} + +$html = $template->render('confirm_deletion', compact('bookmark')); + +respondAndExit(200, 'OK', $html); |
