More API changes
This commit is contained in:
parent
403b87bbda
commit
f9845624d4
@ -14,6 +14,6 @@ class CategoryController {
|
|||||||
static function getAllCategories($hesk_settings) {
|
static function getAllCategories($hesk_settings) {
|
||||||
require_once(__DIR__ . '/../businesslogic/category/CategoryRetriever.php');
|
require_once(__DIR__ . '/../businesslogic/category/CategoryRetriever.php');
|
||||||
|
|
||||||
return json_encode(CategoryRetriever::get_all_categories($hesk_settings));
|
return CategoryRetriever::get_all_categories($hesk_settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
6
api/core/common.php
Normal file
6
api/core/common.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// Contains all common requirements. Nothing more.
|
||||||
|
require_once(__DIR__ . '/../../hesk_settings.inc.php');
|
||||||
|
require_once(__DIR__ . '/../../inc/common.inc.php');
|
||||||
|
require_once(__DIR__ . '/../core/output.php');
|
@ -9,12 +9,18 @@
|
|||||||
namespace DataAccess;
|
namespace DataAccess;
|
||||||
|
|
||||||
use BusinessObjects\Category;
|
use BusinessObjects\Category;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
class CategoryGateway {
|
class CategoryGateway {
|
||||||
static function getAllCategories($hesk_settings) {
|
static function getAllCategories($hesk_settings) {
|
||||||
require_once(__DIR__ . '/../businesslogic/category/Category.php');
|
require_once(__DIR__ . '/../businesslogic/category/Category.php');
|
||||||
|
|
||||||
$sql = 'SELECT * FROM `' . \hesk_dbEscape($hesk_settings['db_pfix']) . 'categories`';
|
if (!function_exists('hesk_dbConnect')) {
|
||||||
|
throw new Exception('Database not loaded!');
|
||||||
|
}
|
||||||
|
hesk_dbConnect();
|
||||||
|
|
||||||
|
$sql = 'SELECT * FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'categories`';
|
||||||
|
|
||||||
$response = hesk_dbQuery($sql);
|
$response = hesk_dbQuery($sql);
|
||||||
|
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: user
|
|
||||||
* Date: 1/16/17
|
|
||||||
* Time: 10:18 PM
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace DataAccess;
|
|
||||||
|
|
||||||
|
|
||||||
use mysqli;
|
|
||||||
|
|
||||||
class Connection {
|
|
||||||
static function connect($hesk_settings) {
|
|
||||||
//-- Return mysqli_connection
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $mysqliConnection mysqli The MySQLi connection obtained from Connection::connect
|
|
||||||
* @return bool true if connection closed, false otherwise
|
|
||||||
*/
|
|
||||||
static function close($mysqliConnection) {
|
|
||||||
return $mysqliConnection->close();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
define('IN_SCRIPT', 1);
|
define('IN_SCRIPT', 1);
|
||||||
|
define('HESK_PATH', '../');
|
||||||
|
|
||||||
// Just call the controller
|
require_once(__DIR__ . '/core/common.php');
|
||||||
require_once(__DIR__ . '/controllers/CategoryController.php');
|
require_once(__DIR__ . '/controllers/CategoryController.php');
|
||||||
require_once(__DIR__ . '/../hesk_settings.inc.php');
|
hesk_load_api_database_functions();
|
||||||
|
|
||||||
\Controllers\Category\CategoryController::getAllCategories($hesk_settings);
|
$categories = \Controllers\Category\CategoryController::getAllCategories($hesk_settings);
|
||||||
|
|
||||||
|
output($categories);
|
@ -190,13 +190,13 @@ function hesk_load_database_functions()
|
|||||||
|
|
||||||
function hesk_load_api_database_functions()
|
function hesk_load_api_database_functions()
|
||||||
{
|
{
|
||||||
require(HESK_PATH . 'api/core/json_error.php');
|
require(__DIR__ . '/../api/core/json_error.php');
|
||||||
// Preferrably use the MySQLi functions
|
// Preferrably use the MySQLi functions
|
||||||
if (function_exists('mysqli_connect')) {
|
if (function_exists('mysqli_connect')) {
|
||||||
require(HESK_PATH . 'api/core/database_mysqli.inc.php');
|
require(__DIR__ . '/../api/core/database_mysqli.inc.php');
|
||||||
} // Default to MySQL
|
} // Default to MySQL
|
||||||
else {
|
else {
|
||||||
require(HESK_PATH . 'api/core/database.inc.php');
|
require(__DIR__ . '/../api/core/database.inc.php');
|
||||||
}
|
}
|
||||||
} // END hesk_load_database_functions()
|
} // END hesk_load_database_functions()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user