Completed
Push — master ( 20e80f...9e4566 )
by Joachim
08:10
created

LabelController::showAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 2
1
<?php
2
3
namespace Loevgaard\PakkelabelsBundle\Controller;
4
5
use Doctrine\ORM\EntityManager;
6
use Loevgaard\PakkelabelsBundle\Entity\Label;
7
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
8
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
9
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
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
        $paginator  = $this->get('knp_paginator');
29
30
        /** @var EntityManager $em */
31
        $em = $this->get('doctrine')->getManager();
32
33
        $qb = $em->createQueryBuilder();
34
        $qb->select('l')
35
            ->from('LoevgaardPakkelabelsBundle:Label', 'l')
36
            ->orderBy('l.id', 'desc')
37
        ;
38
39
        /** @var Label[] $labels */
40
        $labels = $paginator->paginate(
41
            $qb,
42
            $request->query->getInt('page', 1),
43
            100
44
        );
45
46
        return $this->render('@LoevgaardPakkelabels/label/index.html.twig', [
47
            'labels' => $labels,
48
        ]);
49
    }
50
51
    /**
52
     * @Method("GET")
53
     * @Route("/{id}/show", name="loevgaard_pakkelabels_label_show")
54
     *
55
     * @param Label     $label
56
     *
57
     * @return Response
58
     */
59
    public function showAction(Label $label) : Response
60
    {
61
        return $this->render('@LoevgaardPakkelabels/label/show.html.twig', [
62
            'label' => $label,
63
        ]);
64
    }
65
}
66