Passed
Push — master ( bf0ee3...0945b6 )
by FX
02:34
created

ProjectController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A indexAction() 0 18 2
1
<?php
2
3
/**
4
 * Copyright (c) 2017 Francois-Xavier Soubirou.
5
 *
6
 * This file is part of ci-report.
7
 *
8
 * ci-report is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * ci-report is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with ci-report. If not, see <http://www.gnu.org/licenses/>.
20
 */
21
declare(strict_types=1);
22
23
namespace AppBundle\Controller;
24
25
use AppBundle\Entity\Campaign;
26
use AppBundle\Entity\Project;
27
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
28
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
29
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
30
use Symfony\Component\HttpFoundation\Response;
31
32
/**
33
 * Project controller class.
34
 *
35
 * @category  ci-report app
36
 *
37
 * @author    Francois-Xavier Soubirou <[email protected]>
38
 * @copyright 2017 Francois-Xavier Soubirou
39
 * @license   http://www.gnu.org/licenses/   GPLv3
40
 *
41
 * @see      https://ci-report.io
42
 */
43
class ProjectController extends Controller
44
{
45
    /**
46
     * Index action.
47
     *
48
     * @param Project $project The project
49
     *
50
     * @return Response A Response instance
51
     *
52
     * @Route("/project/{refId}", name="project-view")
53
     *
54
     * @ParamConverter("project", options={"mapping": {"refId": "refId"}})
55
     */
56
    public function indexAction(Project $project): Response
57
    {
58
        $campaignsList = $this->getDoctrine()
59
                ->getRepository(Campaign::class)
60
                ->findCampaignsByProject($project);
61
62
        if (count($campaignsList) > 0) {
63
            $lastCampaign = $campaignsList[0];
64
        } else {
65
            $lastCampaign = null;
66
        }
67
68
        return $this->render(
69
            'project/view.html.twig',
70
            array(
71
                'project' => $project,
72
                'lastCampaign' => $lastCampaign,
73
                'campaigns' => $campaignsList,
74
            )
75
        );
76
    }
77
}
78