1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace App\Controller; |
6
|
|
|
|
7
|
|
|
use App\Model\AdminScore; |
8
|
|
|
use App\Repository\AdminScoreRepository; |
9
|
|
|
use Symfony\Component\HttpFoundation\Response; |
10
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* The AdminScoreController serves the search form and results page of the AdminScore tool. |
14
|
|
|
*/ |
15
|
|
|
class AdminScoreController extends XtoolsController |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @inheritDoc |
19
|
|
|
* @codeCoverageIgnore |
20
|
|
|
*/ |
21
|
|
|
public function getIndexRoute(): string |
22
|
|
|
{ |
23
|
|
|
return 'AdminScore'; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Display the AdminScore search form. |
28
|
|
|
* @Route("/adminscore", name="AdminScore") |
29
|
|
|
* @Route("/adminscore/index.php", name="AdminScoreIndexPhp") |
30
|
|
|
* @Route("/scottywong tools/adminscore.php", name="AdminScoreLegacy") |
31
|
|
|
* @Route("/adminscore/{project}", name="AdminScoreProject") |
32
|
|
|
* @return Response |
33
|
|
|
*/ |
34
|
|
|
public function indexAction(): Response |
35
|
|
|
{ |
36
|
|
|
// Redirect if we have a project and user. |
37
|
|
|
if (isset($this->params['project']) && isset($this->params['username'])) { |
38
|
|
|
return $this->redirectToRoute('AdminScoreResult', $this->params); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
return $this->render('adminscore/index.html.twig', [ |
42
|
|
|
'xtPage' => 'AdminScore', |
43
|
|
|
'xtPageTitle' => 'tool-adminscore', |
44
|
|
|
'xtSubtitle' => 'tool-adminscore-desc', |
45
|
|
|
'project' => $this->project, |
46
|
|
|
]); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Display the AdminScore results. |
51
|
|
|
* @Route("/adminscore/{project}/{username}", name="AdminScoreResult") |
52
|
|
|
* @param AdminScoreRepository $adminScoreRepo |
53
|
|
|
* @return Response |
54
|
|
|
* @codeCoverageIgnore |
55
|
|
|
*/ |
56
|
|
|
public function resultAction(AdminScoreRepository $adminScoreRepo): Response |
57
|
|
|
{ |
58
|
|
|
$adminScore = new AdminScore($adminScoreRepo, $this->project, $this->user); |
|
|
|
|
59
|
|
|
|
60
|
|
|
return $this->getFormattedResponse('adminscore/result', [ |
61
|
|
|
'xtPage' => 'AdminScore', |
62
|
|
|
'xtTitle' => $this->user->getUsername(), |
|
|
|
|
63
|
|
|
'as' => $adminScore, |
64
|
|
|
]); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|