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

SwaggerUiController::docFileAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
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