diff options
Diffstat (limited to 'public')
| -rw-r--r-- | public/delete/index.php | 5 | ||||
| -rw-r--r-- | public/index.php | 10 | ||||
| -rw-r--r-- | public/store/index.php | 7 | ||||
| -rw-r--r-- | public/update/index.php | 5 | 
4 files changed, 25 insertions, 2 deletions
diff --git a/public/delete/index.php b/public/delete/index.php index e07129a..9864c9a 100644 --- a/public/delete/index.php +++ b/public/delete/index.php @@ -3,6 +3,7 @@  declare(strict_types=1);  use DTS\BookmarkRepository; +use DTS\Session;  use function DTS\Functions\respondAndExit;  use function DTS\Functions\redirectAndExit; @@ -10,6 +11,8 @@ require_once(__DIR__.'/../../autoload.php');  $config = require_once(__DIR__.'/../../config.php'); +$session = Session::getInstance(); +  if (filter_input(INPUT_SERVER, 'REQUEST_METHOD') !== 'POST') {      respondAndExit(405, 'Method Not Allowed');  } @@ -28,4 +31,6 @@ if (!$bookmarks->delete($bookmark)) {      respondAndExit(500, 'Internal Server Error');  } +$session->set('message', 'Bookmark Deleted'); +  redirectAndExit('/'); diff --git a/public/index.php b/public/index.php index 7453506..025c9ec 100644 --- a/public/index.php +++ b/public/index.php @@ -3,6 +3,7 @@  declare(strict_types=1);  use DTS\BookmarkRepository; +use DTS\Session;  use DTS\Template;  use function DTS\Functions\respondAndExit; @@ -10,6 +11,8 @@ require_once(__DIR__.'/../autoload.php');  $config = require_once(__DIR__.'/../config.php'); +$session = Session::getInstance(); +  $bookmarks = new BookmarkRepository($config['path_to_repository']);  $template = new Template($config['path_to_templates']); @@ -24,6 +27,11 @@ if ($tag !== null) {  $bookmarks->sort($sort === 'asc'); -$html = $template->render('index', compact('bookmarks')); +$message = $session->get('message'); + +$html = $template->render('index', compact( +    'bookmarks', +    'message' +));  respondAndExit(200, 'OK', $html); diff --git a/public/store/index.php b/public/store/index.php index 2a84c59..45765d5 100644 --- a/public/store/index.php +++ b/public/store/index.php @@ -4,13 +4,16 @@ declare(strict_types=1);  use DTS\Bookmark;  use DTS\BookmarkRepository; -use function DTS\Functions\respondAndExit; +use DTS\Session;  use function DTS\Functions\redirectAndExit; +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') !== 'POST') {      respondAndExit(405, 'Method Not Allowed');  } @@ -30,4 +33,6 @@ if (!$bookmarks->add($bookmark)) {      respondAndExit(500, 'Internal Server Error');  } +$session->set('message', 'Bookmark Added'); +  redirectAndExit('/'); diff --git a/public/update/index.php b/public/update/index.php index fa6b482..50d0dcf 100644 --- a/public/update/index.php +++ b/public/update/index.php @@ -3,6 +3,7 @@  declare(strict_types=1);  use DTS\BookmarkRepository; +use DTS\Session;  use function DTS\Functions\respondAndExit;  use function DTS\Functions\redirectAndExit; @@ -10,6 +11,8 @@ require_once(__DIR__.'/../../autoload.php');  $config = require_once(__DIR__.'/../../config.php'); +$session = Session::getInstance(); +  if (filter_input(INPUT_SERVER, 'REQUEST_METHOD') !== 'POST') {      respondAndExit(405, 'Method Not Allowed');  } @@ -32,4 +35,6 @@ if (!$bookmarks->update($bookmark)) {      respondAndExit(500, 'Internal Server Error');  } +$session->set('message', 'Bookmark Updated'); +  redirectAndExit('/');  | 
