forked from amargapinho/GameZone
-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.php
41 lines (30 loc) · 862 Bytes
/
api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
require_once __DIR__ . '/vendor/autoload.php';
use GameZone\Category;
use GameZone\Game;
use GameZone\Json;
if(isset($_GET['action'], $_GET['value'])){
switch ($_GET['action']){
case 'getGame':
Json::send(Game::getGame($_GET['value'])->loadCategories());
break;
case 'getCategory':
Json::send(Category::getCategory($_GET['value']));
break;
case 'getImage':
die(Game::getGameByName($_GET['value'])->getTwitchImage());
case 'switchFavorite':
$game = Game::getGame($_GET['value']);
$game->setWishlisted(!$game->isWishlisted())->save();
break;
case 'deleteGame':
Game::getGame($_GET['value'])->delete();
break;
case 'deleteCategory':
Category::getCategory($_GET['value'])->delete();
break;
case 'recover':
Game::getGame($_GET['value'])->recover();
break;
}
}