Added proper DI and autoloading to make things simpler for the actual logic'
parent
ecbd2fd94a
commit
2ef67de718
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Core;
|
||||
|
||||
// Responsible for loading in all necessary classes. AKA a poor man's DI solution.
|
||||
use BusinessLogic\Category\CategoryRetriever;
|
||||
use DataAccess\CategoryGateway;
|
||||
|
||||
class DependencyManager {
|
||||
public $get;
|
||||
|
||||
function __construct() {
|
||||
$this->get = array();
|
||||
|
||||
$this->get['CategoryGateway'] = new CategoryGateway();
|
||||
$this->get['CategoryRetriever'] = new CategoryRetriever($this->get['CategoryGateway']);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
// Responsible for loading in all necessary scripts and kicking off the DependencyManager
|
||||
|
||||
define('IN_SCRIPT', 1);
|
||||
define('HESK_PATH', '../');
|
||||
require_once(__DIR__ . '/core/common.php');
|
||||
require_once(__DIR__ . '/Link.php');
|
||||
require_once(__DIR__ . '/../hesk_settings.inc.php');
|
||||
|
||||
// FILES
|
||||
require_once(__DIR__ . '/http_response_code.php');
|
||||
require_once(__DIR__ . '/dao/category/CategoryGateway.php');
|
||||
require_once(__DIR__ . '/businesslogic/category/CategoryRetriever.php');
|
||||
require_once(__DIR__ . '/businesslogic/category/Category.php');
|
||||
require_once(__DIR__ . '/controllers/CategoryController.php');
|
||||
|
||||
hesk_load_api_database_functions();
|
||||
|
||||
// HESK files that require database access
|
||||
require_once(__DIR__ . '/../inc/custom_fields.inc.php');
|
||||
|
||||
require_once(__DIR__ . '/DependencyManager.php');
|
||||
|
||||
$applicationContext = new \Core\DependencyManager();
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
function output($data, $status_code = 200) {
|
||||
http_response_code($status_code);
|
||||
header('Content-Type: application/json');
|
||||
print json_encode($data);
|
||||
return http_response_code($status_code);
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
// For 4.3.0 <= PHP <= 5.4.0
|
||||
if (function_exists('http_response_code') === false) {
|
||||
function http_response_code($newcode = NULL) {
|
||||
static $code = 200;
|
||||
if ($newcode !== NULL) {
|
||||
header('X-PHP-Response-Code: ' . $newcode, true, $newcode);
|
||||
if (!headers_sent()) {
|
||||
$code = $newcode;
|
||||
}
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue