Completed
Pull Request — master (#125)
by
unknown
13:06
created

SwaggerUiController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A indexAction() 0 8 1
A docFileAction() 0 13 1
1
<?php
2
3
namespace AppBundle\Controller;
4
5
use Buzz\Message\Request;
6
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7
use Symfony\Component\HttpFoundation\JsonResponse;
8
use Symfony\Component\HttpFoundation\Response;
9
10
class SwaggerUiController extends Controller
11
{
12
    /**
13
     * Render SwaggerUI template.
14
     *
15
     * @return Response
16
     */
17
    public function indexAction()
18
    {
19
        $docFileUrl = $this->generateUrl('swagger_ui_doc_file');
20
21
        return $this->render(':SwaggerUI:index.html.twig', [
22
            'doc_file_url' => $docFileUrl
23
        ]);
24
    }
25
26
    /**
27
     * @return JsonResponse
28
     */
29
    public function docFileAction()
30
    {
31
        $dir = sprintf(
32
            '%s/../%s',
33
            $this->get('kernel')->getRootDir(),
34
            'doc/'
35
        );
36
37
        $docFile = json_decode(file_get_contents($dir . 'theatre.json'), true);
38
        $docFile['host'] = $this->container->get('router')->getContext()->getHost();
39
40
        return new JsonResponse($docFile);
41
    }
42
}
43