Completed
Push — master ( dd5924...1cc36f )
by Joachim
62:06 queued 54:44
created

LabelController::indexAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace Loevgaard\PakkelabelsBundle\Controller;
4
5
use Loevgaard\PakkelabelsBundle\Entity\Label;
6
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
7
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
8
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9
use Symfony\Component\HttpFoundation\BinaryFileResponse;
10
use Symfony\Component\HttpFoundation\Request;
11
use Symfony\Component\HttpFoundation\Response;
12
13
/**
14
 * @Route("/label")
15
 */
16
class LabelController extends Controller
17
{
18
    /**
19
     * @Method("GET")
20
     * @Route("", name="loevgaard_pakkelabels_label_index")
21
     *
22
     * @param Request $request
23
     *
24
     * @return Response
25
     */
26 View Code Duplication
    public function indexAction(Request $request)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
    {
28
        $repos = $this->get('loevgaard_pakkelabels.label_repository');
29
30
        /** @var Label[] $countryMappings */
31
        $labels = $repos->findAllWithPaging($request->query->getInt('page', 1));
32
33
        return $this->render('@LoevgaardPakkelabels/label/index.html.twig', [
34
            'labels' => $labels,
35
        ]);
36
    }
37
38
    /**
39
     * @Method("GET")
40
     * @Route("/{id}/show", name="loevgaard_pakkelabels_label_show")
41
     *
42
     * @param Label $label
43
     *
44
     * @return Response
45
     */
46
    public function showAction(Label $label): Response
47
    {
48
        return $this->render('@LoevgaardPakkelabels/label/show.html.twig', [
49
            'label' => $label,
50
        ]);
51
    }
52
53
    /**
54
     * @Method("GET")
55
     * @Route("/{id}/image", name="loevgaard_pakkelabels_label_image")
56
     *
57
     * @param Label $label
58
     *
59
     * @return BinaryFileResponse
60
     */
61
    public function imageAction(Label $label): BinaryFileResponse
62
    {
63
        $labelFactory = $this->get('loevgaard_pakkelabels.label_file_factory');
64
65
        // @todo remember to catch exception, maybe create a new exception class
66
        $labelFile = $labelFactory->create($label, true);
67
68
        return new BinaryFileResponse($labelFile);
69
    }
70
}
71