|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Entry point controller. |
|
4
|
|
|
*/ |
|
5
|
|
|
namespace Graviton\AnalyticsBundle\Controller; |
|
6
|
|
|
|
|
7
|
|
|
use Graviton\AnalyticsBundle\Manager\ServiceManager; |
|
8
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
|
9
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* @author List of contributors <https://github.com/libgraviton/graviton/graphs/contributors> |
|
13
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
14
|
|
|
* @link http://swisscom.ch |
|
15
|
|
|
*/ |
|
16
|
|
|
class DefaultController |
|
17
|
|
|
{ |
|
18
|
|
|
/** @var ServiceManager */ |
|
19
|
|
|
private $serviceManager; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* DefaultController constructor. |
|
23
|
|
|
* @param ServiceManager $serviceManager Parsing the requested date |
|
24
|
|
|
*/ |
|
25
|
|
|
public function __construct( |
|
26
|
|
|
ServiceManager $serviceManager |
|
27
|
|
|
) { |
|
28
|
|
|
$this->serviceManager = $serviceManager; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @return JsonResponse |
|
33
|
|
|
*/ |
|
34
|
|
|
public function indexAction() |
|
35
|
|
|
{ |
|
36
|
|
|
$data = $this->serviceManager->getServices(); |
|
37
|
|
|
|
|
38
|
|
|
return new JsonResponse($data); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @return Response |
|
43
|
|
|
*/ |
|
44
|
|
|
public function optionsAction() |
|
45
|
|
|
{ |
|
46
|
|
|
$resp = new Response(); |
|
47
|
|
|
$resp->setStatusCode(Response::HTTP_NO_CONTENT); |
|
48
|
|
|
$resp->headers->set("Access-Control-Allow-Methods", "GET, OPTIONS"); |
|
49
|
|
|
return $resp; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @return JsonResponse |
|
54
|
|
|
*/ |
|
55
|
|
|
public function serviceAction() |
|
56
|
|
|
{ |
|
57
|
|
|
$data = $this->serviceManager->getData(); |
|
58
|
|
|
|
|
59
|
|
|
return new JsonResponse($data); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @return JsonResponse |
|
64
|
|
|
*/ |
|
65
|
|
|
public function serviceSchemaAction() |
|
66
|
|
|
{ |
|
67
|
|
|
$data = $this->serviceManager->getSchema(); |
|
68
|
|
|
|
|
69
|
|
|
return new JsonResponse($data); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|