mirror of
https://github.com/standardebooks/web.git
synced 2025-07-19 04:44:48 -04:00
Use HTTP code enums instead of ints
This commit is contained in:
parent
3f822b85c3
commit
3050ab7219
28 changed files with 56 additions and 56 deletions
|
@ -11,7 +11,7 @@ try{
|
|||
|
||||
if(isset($_SESSION['is-vote-created']) && $_SESSION['is-vote-created'] == $vote->UserId){
|
||||
$created = true;
|
||||
http_response_code(201);
|
||||
http_response_code(Enums\HttpCode::Created->value);
|
||||
session_unset();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ try{
|
|||
}
|
||||
|
||||
if($exception){
|
||||
http_response_code(422);
|
||||
http_response_code(Enums\HttpCode::UnprocessableContent->value);
|
||||
session_unset();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,12 +18,12 @@ try{
|
|||
|
||||
if($requestType == Enums\HttpRequestType::Web){
|
||||
$_SESSION['is-vote-created'] = $vote->UserId;
|
||||
http_response_code(303);
|
||||
http_response_code(Enums\HttpCode::SeeOther->value);
|
||||
header('Location: ' . $vote->Url);
|
||||
}
|
||||
else{
|
||||
// Access via Enums\HttpRequestType::Rest api; 201 CREATED with location
|
||||
http_response_code(201);
|
||||
http_response_code(Enums\HttpCode::Created->value);
|
||||
header('Location: ' . $vote->Url);
|
||||
}
|
||||
}
|
||||
|
@ -33,11 +33,11 @@ catch(Exceptions\InvalidPollVoteException $ex){
|
|||
$_SESSION['exception'] = $ex;
|
||||
|
||||
// Access via form; 303 redirect to the form, which will emit a 422 Unprocessable Entity
|
||||
http_response_code(303);
|
||||
http_response_code(Enums\HttpCode::SeeOther->value);
|
||||
header('Location: /polls/' . (HttpInput::Str(GET, 'pollurlname') ?? '') . '/votes/new');
|
||||
}
|
||||
else{
|
||||
// Access via Enums\HttpRequestType::Rest api; 422 Unprocessable Entity
|
||||
http_response_code(422);
|
||||
http_response_code(Enums\HttpCode::UnprocessableContent->value);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue