Completed
Push — master ( 47d58a...2d77ff )
by Joachim
02:52
created

ReportController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 6
dl 0
loc 45
ccs 0
cts 24
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B indexAction() 0 24 1
A showAction() 0 6 1
1
<?php
2
3
namespace Loevgaard\DandomainConsignmentBundle\Controller;
4
5
use Doctrine\ORM\EntityManager;
6
use Loevgaard\DandomainConsignment\Entity\Report;
7
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8
use Symfony\Component\HttpFoundation\Request;
9
use Symfony\Component\HttpFoundation\Response;
10
11
class ReportController extends Controller
12
{
13
    /**
14
     * @param Request $request
15
     * @return Response
16
     */
17
    public function indexAction(Request $request)
18
    {
19
        /** @var EntityManager $em */
20
        $em = $this->getDoctrine()->getManager();
21
        $paginator = $this->get('knp_paginator');
22
23
        $qb = $em->createQueryBuilder();
24
        $qb->select('r, s')
25
            ->from('Loevgaard\DandomainConsignment\Entity\Report', 'r')
26
            ->leftJoin('r.stockMovements', 's')
27
            ->addOrderBy('r.createdAt', 'desc')
28
        ;
29
30
        /** @var Report[] $reports */
31
        $reports = $paginator->paginate(
32
            $qb->getQuery(),
33
            $request->query->getInt('page', 1),
34
            $request->query->getInt('limit', 50)
35
        );
36
37
        return $this->render('@LoevgaardDandomainConsignment/report/index.html.twig', [
38
            'reports' => $reports
39
        ]);
40
    }
41
42
    /**
43
     * @param ConsignmentReport $consignmentReport
44
     * @return Response
45
     *
46
     * @Method("GET")
47
     * @Route("/{id}", name="admin_consignment_report_show")
48
     */
49
    public function showAction(ConsignmentReport $consignmentReport)
50
    {
51
        return $this->render('admin/consignmentreport/show.html.twig', [
52
            'consignmentReport' => $consignmentReport
53
        ]);
54
    }
55
}
56