Typos in API code fixed

This commit is contained in:
2026-06-15 15:20:33 +02:00
parent 9dfb60fb9a
commit 7429cd367d
16 changed files with 55 additions and 50 deletions

View File

@@ -1,6 +1,9 @@
<?php
namespace api\classes;
use JetBrains\PhpStorm\NoReturn;
class API
{
public $conn;
@@ -9,7 +12,7 @@ class API
# The user uuid that requested the API
protected $user_uuid;
# $user_type is either an API call (api) or an call from the frontend (frontend)
# $user_type is either an API call (api) or a call from the frontend (frontend)
protected $user_type;
# Either GET POST PUT or DELETE
@@ -44,7 +47,7 @@ class API
public $baseQuery = false;
# Used for the general get function, this prevents SQL injecting by only allowing these columns instead of
# Whatever the user inputs straigt into the query.
# Whatever the user inputs straight into the query.
public $allowedGetColumns = false;
# Cache the columns of the tables for some small performance improvements.
@@ -573,7 +576,7 @@ class API
# api will need to post with an application/json type Content type.
# frontend will post with application/x-www-form-urlencoded content type but also is capable of application/json
# frontend can also post multipart/form-data
# GET requests dont have an content type
# GET requests don't have a content type
$contentType = $_SERVER['CONTENT_TYPE'] ?? '';
@@ -610,6 +613,7 @@ class API
return $this->user_uuid;
}
#[NoReturn]
public function apiOutput($code = 200, $data = [], $frontendMessage = false)
{
if ($this->user_type === 'api') {
@@ -629,10 +633,10 @@ class API
if (in_array($this->request_method, ['POST', 'PUT', 'DELETE'])) {
http_response_code($code);
if ($this->return_url) { # sometimes the PUT doesnt need an return or response set (Think of js actions to api from frontend)
if ($this->return_url) { # sometimes the PUT doesn't need a return or response set (Think of js actions to api from frontend)
$_SESSION['response'] = json_encode($data);
# When a request is successfull the api will recieve the data, the frontend needs a friendly message
# When a request is successfully the api will receive the data, the frontend needs a friendly message
if ($frontendMessage) {
$_SESSION['response'] = json_encode([key($data) => __($frontendMessage)]);
}