blob: e07129ad8d4cc637cd928612c2a72c2452f3cb0a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
<?php
declare(strict_types=1);
use DTS\BookmarkRepository;
use function DTS\Functions\respondAndExit;
use function DTS\Functions\redirectAndExit;
require_once(__DIR__.'/../../autoload.php');
$config = require_once(__DIR__.'/../../config.php');
if (filter_input(INPUT_SERVER, 'REQUEST_METHOD') !== 'POST') {
respondAndExit(405, 'Method Not Allowed');
}
$id = filter_input(INPUT_POST, 'id');
$bookmarks = new BookmarkRepository($config['path_to_repository']);
$bookmark = $bookmarks->find($id);
if ($bookmark === null) {
respondAndExit(404, 'Not Found');
}
if (!$bookmarks->delete($bookmark)) {
respondAndExit(500, 'Internal Server Error');
}
redirectAndExit('/');
|