CampaignController   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 1

1 Method

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