1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Graviton\ApiBundle\Controller; |
4
|
|
|
|
5
|
|
|
use Graviton\ApiBundle\Service\ApiService; |
6
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
7
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
8
|
|
|
use Symfony\Component\HttpFoundation\RequestStack; |
9
|
|
|
|
10
|
|
|
class RestController |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var ContainerInterface |
14
|
|
|
*/ |
15
|
|
|
protected $container; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var ApiService |
19
|
|
|
*/ |
20
|
|
|
protected $apiService; |
21
|
|
|
|
22
|
|
|
public function __construct(ApiService $apiService) |
23
|
|
|
{ |
24
|
|
|
$this->apiService = $apiService; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
public function indexAction() |
29
|
|
|
{ |
30
|
|
|
$response = new JsonResponse(); |
31
|
|
|
$data = $this->apiService->getRoutes(); |
32
|
|
|
$response->setData($data); |
33
|
|
|
|
34
|
|
|
return $response; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
public function schemaAction() |
39
|
|
|
{ |
40
|
|
|
$response = new JsonResponse(); |
41
|
|
|
$data = $this->apiService->getSchema(); |
42
|
|
|
$response->setData($data); |
43
|
|
|
|
44
|
|
|
return $response; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
public function getAction() |
49
|
|
|
{ |
50
|
|
|
$response = new JsonResponse(); |
51
|
|
|
$data = $this->apiService->getData(); |
52
|
|
|
$response->setData($data); |
53
|
|
|
|
54
|
|
|
return $response; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function optionsAction() |
58
|
|
|
{ |
59
|
|
|
$response = new JsonResponse(); |
60
|
|
|
$response->setData(['something in options']); |
61
|
|
|
|
62
|
|
|
return $response; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
|
66
|
|
|
public function putAction() |
67
|
|
|
{ |
68
|
|
|
$response = new JsonResponse(); |
69
|
|
|
$response->setData(['something in put']); |
70
|
|
|
|
71
|
|
|
return $response; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
public function patchAction() |
76
|
|
|
{ |
77
|
|
|
$response = new JsonResponse(); |
78
|
|
|
$response->setContent(['something in patch']); |
79
|
|
|
|
80
|
|
|
return $response; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|