Completed
Pull Request — develop (#579)
by
unknown
15:32 queued 10:40
created

DefaultController::serviceAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 2
1
<?php
2
/**
3
 * Entry point controller.
4
 */
5
namespace Graviton\AnalyticsBundle\Controller;
6
7
use Graviton\AnalyticsBundle\Request\ParamConverter\ServiceConverter;
8
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9
use Symfony\Component\HttpFoundation\JsonResponse;
10
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
11
use Symfony\Component\HttpFoundation\Request;
12
13
/**
14
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
15
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
16
 * @link     http://swisscom.ch
17
 */
18
class DefaultController extends Controller
19
{
20
21
    /**
22
     * @param ServiceConverter $manager Api Service to Find the Needed response data
23
     * @ParamConverter("manager", converter="graviton.analytics.request_service_converter")
24
     * @return JsonResponse
25
     */
26
    public function indexAction(ServiceConverter $manager)
27
    {
28
        $data = $manager->getServices();
29
30
        return new JsonResponse($data);
31
    }
32
33
    /**
34
     * @param ServiceConverter $manager Api Service to Find the Needed response data
35
     * @param Request          $request Sf Request data
36
     * @ParamConverter("manager", converter="graviton.analytics.request_service_converter")
37
     * @return JsonResponse
38
     */
39
    public function serviceAction(ServiceConverter $manager, Request $request)
40
    {
41
        $data = $manager->getData($request->get('service'));
42
43
        return new JsonResponse($data);
44
    }
45
46
    /**
47
     * @param ServiceConverter $manager Api Service to Find the Needed response data
48
     * @param Request          $request Sf Request data
49
     * @ParamConverter("manager", converter="graviton.analytics.request_service_converter")
50
     * @return JsonResponse
51
     */
52
    public function serviceSchemaAction(ServiceConverter $manager, Request $request)
53
    {
54
        $data = $manager->getSchema($request->get('service'));
55
56
        return new JsonResponse($data);
57
    }
58
}
59