Completed
Pull Request — development (#824)
by
unknown
04:40
created

SupportController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Oc\Controller\Backend;
6
7
//use Doctrine\DBAL\Connection;
8
//use Oc\Repository\CachesRepository;
9
use Oc\Repository\CacheReportsRepository;
10
use Oc\Repository\CacheStatusModifiedRepository;
11
use Oc\Repository\CacheStatusRepository;
12
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
13
use Symfony\Component\HttpFoundation\Request;
14
use Symfony\Component\HttpFoundation\Response;
15
use Symfony\Component\Routing\Annotation\Route;
16
17
//use Oc\Repository\UserRepository;
18
19
/**
20
 * Class SupportController
21
 *
22
 * @package Oc\Controller\Backend
23
 */
24
class SupportController extends AbstractController
25
{
26
    private $cacheReportsRepository;
27
28
    private $cacheStatusModifiedRepository;
29
30
    private $cacheStatusRepository;
31
32
    /**
33
     * SupportController constructor.
34
     *
35
     * @param CacheReportsRepository $cacheReportsRepository
36
     * @param CacheStatusModifiedRepository $cacheStatusModifiedRepository
37
     * @param CacheStatusRepository $cacheStatusRepository
38
     */
39
    public function __construct(
40
        CacheReportsRepository $cacheReportsRepository,
41
        CacheStatusModifiedRepository $cacheStatusModifiedRepository,
42
        CacheStatusRepository $cacheStatusRepository
43
    ) {
44
        $this->cacheReportsRepository = $cacheReportsRepository;
45
        $this->cacheStatusModifiedRepository = $cacheStatusModifiedRepository;
46
        $this->cacheStatusRepository = $cacheStatusRepository;
47
    }
48
49
    /**
50
     * @param Request $request
51
     * @Route("/support", name="support_index")
52
     *
53
     * @return Response
54
     */
55
    public function index(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
56
    : Response {
57
        return $this->render('backend/support/index.html.twig', []);
58
    }
59
60
    /**
61
     * @return Response
62
     * @throws \Oc\Repository\Exception\RecordsNotFoundException
63
     * @Route("/reportedCaches", name="support_reported_caches")
64
     */
65
    public function listReportedCaches()
66
    : Response
67
    {
68
        $fetchedReports = $this->getReportedCaches();
69
70
        return $this->render('backend/support/reportedCaches.html.twig', ['reportedCaches_by_id' => $fetchedReports]);
71
    }
72
73
    /**
74
     * @param string $repID
75
     *
76
     * @return array
77
     * @Route("/repCaches/{repID}", name="support_reported_cache")
78
     */
79
    public function search_by_report_id(string $repID)
80
    : Response {
81
        $fetchedReport = $this->cacheReportsRepository->fetchOneBy(['id' => $repID]);
82
83
        $fetchedStatus = $this->cacheStatusRepository->fetchAll();
84
85
        $fetchedStatusModfied = $this->cacheStatusModifiedRepository->fetchBy(['cache_id' => $fetchedReport->cacheid]);
86
87
        return $this->render(
88
            'backend/support/reportedCacheDetails.html.twig', [
89
                                                                'reported_cache_by_id' => $fetchedReport,
90
                                                                'cache_status' => $fetchedStatus,
91
                                                                'report_status_modified' => $fetchedStatusModfied
92
                                                            ]
93
        );
94
    }
95
96
    /**
97
     * @return array
98
     * @throws \Oc\Repository\Exception\RecordsNotFoundException
99
     */
100
    public function getReportedCaches()
101
    : array
102
    {
103
        $fetchedReports = $this->cacheReportsRepository->fetchAll();
104
105
        return $fetchedReports;
106
    }
107
}
108