Completed
Push — master ( 8e1573...db6321 )
by
unknown
16:08 queued 08:39
created

TestController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 40
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace AppBundle\Controller;
4
5
use MediaMonks\SonataMediaBundle\ParameterBag\ImageParameterBag;
6
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
7
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8
use Symfony\Component\HttpFoundation\JsonResponse;
9
use Symfony\Component\HttpFoundation\Response;
10
11
class TestController extends Controller
12
{
13
    /**
14
     * @Route("/ready")
15
     */
16
    public function foobarAction()
17
    {
18
        return new Response('MediaMonks Functional Test App Ready');
19
    }
20
21
    /**
22
     * @Route("/twig")
23
     * @return Response
24
     */
25
    public function twigAction()
26
    {
27
        return $this->render(
28
            'AppBundle:Test:index.html.twig',
29
            [
30
                'media' => $this->getDoctrine()->getManager()->find('AppBundle:Media', 1),
31
            ]
32
        );
33
    }
34
35
    /**
36
     * @Route("/api")
37
     * @return Response
38
     */
39
    public function apiAction()
40
    {
41
        $media = $this->getDoctrine()->getManager()->find('AppBundle:Media', 1);
42
43
        $url = $this->get('mediamonks.sonata_media.generator.url_generator.image')->generate(
44
            $media,
45
            new ImageParameterBag(400, 300)
46
        );
47
48
        return new JsonResponse(['url' => $url]);
49
    }
50
}
51