Update framework standards

This commit is contained in:
Alex Cabal 2024-09-09 20:34:30 -05:00
parent 232e056299
commit 09a91a998e
17 changed files with 282 additions and 98 deletions

View file

@ -2,7 +2,7 @@
use function Safe\session_unset;
try{
HttpInput::ValidateRequestMethod([HttpMethod::Post]);
HttpInput::ValidateRequestMethod([Enums\HttpMethod::Post]);
session_start();
@ -16,19 +16,19 @@ try{
session_unset();
if($requestType == HttpRequestType::Web){
if($requestType == Enums\HttpRequestType::Web){
$_SESSION['is-vote-created'] = $vote->UserId;
http_response_code(303);
header('Location: ' . $vote->Url);
}
else{
// Access via HttpRequestType::Rest api; 201 CREATED with location
// Access via Enums\HttpRequestType::Rest api; 201 CREATED with location
http_response_code(201);
header('Location: ' . $vote->Url);
}
}
catch(Exceptions\InvalidPollVoteException $ex){
if($requestType == HttpRequestType::Web){
if($requestType == Enums\HttpRequestType::Web){
$_SESSION['vote'] = $vote;
$_SESSION['exception'] = $ex;
@ -37,7 +37,7 @@ catch(Exceptions\InvalidPollVoteException $ex){
header('Location: /polls/' . (HttpInput::Str(GET, 'pollurlname') ?? '') . '/votes/new');
}
else{
// Access via HttpRequestType::Rest api; 422 Unprocessable Entity
// Access via Enums\HttpRequestType::Rest api; 422 Unprocessable Entity
http_response_code(422);
}
}