diff options
| author | David T. Sadler <davidtsadler@googlemail.com> | 2021-10-26 21:07:43 +0100 |
|---|---|---|
| committer | David T. Sadler <davidtsadler@googlemail.com> | 2021-10-26 21:07:43 +0100 |
| commit | ae205d810b62dce5e3e11aef07358c11ded48c77 (patch) | |
| tree | 0196ae98aefb93b719d6b21cc065e22c1ecf992b /public | |
| parent | d4122f116c937e0ec509d8cefe540146ec27a0cd (diff) | |
Implement old
Diffstat (limited to 'public')
| -rw-r--r-- | public/create/index.php | 6 | ||||
| -rw-r--r-- | public/edit/index.php | 6 | ||||
| -rw-r--r-- | public/store/index.php | 5 | ||||
| -rw-r--r-- | public/update/index.php | 5 |
4 files changed, 20 insertions, 2 deletions
diff --git a/public/create/index.php b/public/create/index.php index 786b8f2..7464f71 100644 --- a/public/create/index.php +++ b/public/create/index.php @@ -4,6 +4,7 @@ declare(strict_types=1); use DTS\Bookmark; use DTS\Errors; +use DTS\Old; use DTS\Session; use DTS\Template; @@ -19,6 +20,8 @@ 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']); @@ -27,7 +30,8 @@ $bookmark = new Bookmark(); $html = $template->render('create', compact( 'bookmark', - 'errors' + 'errors', + 'old' )); respondAndExit(200, 'OK', $html); diff --git a/public/edit/index.php b/public/edit/index.php index fba5a90..b1efeec 100644 --- a/public/edit/index.php +++ b/public/edit/index.php @@ -4,6 +4,7 @@ declare(strict_types=1); use DTS\BookmarkRepository; use DTS\Errors; +use DTS\Old; use DTS\Session; use DTS\Template; @@ -19,6 +20,8 @@ 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()); $id = filter_input(INPUT_GET, 'id'); @@ -35,7 +38,8 @@ if ($bookmark === null) { $html = $template->render('edit', compact( 'bookmark', - 'errors' + 'errors', + 'old' )); respondAndExit(200, 'OK', $html); diff --git a/public/store/index.php b/public/store/index.php index 5279e69..8bd0b7f 100644 --- a/public/store/index.php +++ b/public/store/index.php @@ -4,6 +4,7 @@ declare(strict_types=1); use DTS\Bookmark; use DTS\BookmarkRepository; +use DTS\Old; use DTS\Session; use DTS\Validator; @@ -20,6 +21,10 @@ if (filter_input(INPUT_SERVER, 'REQUEST_METHOD') !== 'POST') { respondAndExit(405, 'Method Not Allowed'); } +$old = new Old($_REQUEST); + +$session->set('old', $old); + $validator = new Validator($_REQUEST); if ($validator->errors->count()) { diff --git a/public/update/index.php b/public/update/index.php index d194dbd..1bccfa4 100644 --- a/public/update/index.php +++ b/public/update/index.php @@ -3,6 +3,7 @@ declare(strict_types=1); use DTS\BookmarkRepository; +use DTS\Old; use DTS\Session; use DTS\Validator; @@ -29,6 +30,10 @@ if ($bookmark === null) { respondAndExit(404, 'Not Found'); } +$old = new Old($_REQUEST); + +$session->set('old', $old); + $validator = new Validator($_REQUEST); if ($validator->errors->count()) { |
