Category Controller is working
This commit is contained in:
parent
93431e9a98
commit
aff8dadd27
@ -11,11 +11,17 @@ namespace Controllers\Category;
|
||||
use BusinessLogic\Category\CategoryRetriever;
|
||||
|
||||
class CategoryController {
|
||||
function get($i) {
|
||||
print json_encode(intval($i));
|
||||
function get($id) {
|
||||
$categories = self::getAllCategories();
|
||||
output($categories[$id]);
|
||||
}
|
||||
|
||||
static function getAllCategories($hesk_settings) {
|
||||
static function printAllCategories() {
|
||||
output(self::getAllCategories());
|
||||
}
|
||||
|
||||
private static function getAllCategories() {
|
||||
global $hesk_settings;
|
||||
require_once(__DIR__ . '/../businesslogic/category/CategoryRetriever.php');
|
||||
|
||||
return CategoryRetriever::get_all_categories($hesk_settings);
|
||||
|
@ -8,27 +8,7 @@ require(__DIR__ . '/../hesk_settings.inc.php');
|
||||
|
||||
// Controllers
|
||||
require(__DIR__ . '/controllers/CategoryController.php');
|
||||
|
||||
|
||||
class HomeController
|
||||
{
|
||||
|
||||
function get($i){
|
||||
echo 'You have got to home :) Val:' . intval($i);
|
||||
}
|
||||
|
||||
function post(){
|
||||
echo 'You have posted to home';
|
||||
}
|
||||
|
||||
function put(){
|
||||
echo 'You have put to home';
|
||||
}
|
||||
|
||||
function delete(){
|
||||
echo 'You have deleted the home :(';
|
||||
}
|
||||
}
|
||||
hesk_load_api_database_functions();
|
||||
|
||||
function handle404() {
|
||||
http_response_code(404);
|
||||
@ -43,7 +23,8 @@ function assertApiIsEnabled() {
|
||||
Link::before('assertApiIsEnabled');
|
||||
|
||||
Link::all(array(
|
||||
'/' => 'assertApiIsEnabled',
|
||||
'/test/{i}' => '\Controllers\Category\CategoryController',
|
||||
// Categories
|
||||
'/v1/categories' => '\Controllers\Category\CategoryController::printAllCategories',
|
||||
'/v1/categories/{i}' => '\Controllers\Category\CategoryController',
|
||||
'404' => 'handle404'
|
||||
));
|
Loading…
x
Reference in New Issue
Block a user