1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Controller; |
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
6
|
|
|
use Symfony\Component\HttpFoundation\BinaryFileResponse; |
7
|
|
|
use Symfony\Component\HttpFoundation\Response; |
8
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
9
|
|
|
|
10
|
|
|
class BaseController extends AbstractController |
11
|
|
|
{ |
12
|
1 |
|
#[Route('/', name: 'home')] |
13
|
|
|
public function home(): Response |
14
|
|
|
{ |
15
|
1 |
|
return $this->render('home.html.twig'); |
16
|
|
|
} |
17
|
|
|
|
18
|
1 |
|
#[Route('/about', name: 'about')] |
19
|
|
|
public function about(): Response |
20
|
|
|
{ |
21
|
1 |
|
return $this->render('about.html.twig'); |
22
|
|
|
} |
23
|
|
|
|
24
|
1 |
|
#[Route('/report', name: 'report')] |
25
|
|
|
public function report(): Response |
26
|
|
|
{ |
27
|
1 |
|
return $this->render('report.html.twig'); |
28
|
|
|
} |
29
|
|
|
|
30
|
1 |
|
#[Route('/lucky', name: 'lucky')] |
31
|
|
|
public function lucky(): Response |
32
|
|
|
{ |
33
|
1 |
|
$number = random_int(0, 100); |
34
|
|
|
|
35
|
1 |
|
$data = [ |
36
|
1 |
|
'number' => $number, |
37
|
1 |
|
]; |
38
|
|
|
|
39
|
1 |
|
return $this->render('lucky.html.twig', $data); |
40
|
|
|
} |
41
|
|
|
|
42
|
1 |
|
#[Route('/metrics', name: 'metrics')] |
43
|
|
|
public function metrics(): Response |
44
|
|
|
{ |
45
|
1 |
|
return $this->render('metrics.html.twig'); |
46
|
|
|
} |
47
|
|
|
|
48
|
1 |
|
#[Route('/docs/old_metrics/index', name: 'old_metrics')] |
49
|
|
|
public function oldMetrics(): Response |
50
|
|
|
{ |
51
|
1 |
|
$projectDir = $this->getParameter('kernel.project_dir'); |
52
|
|
|
|
53
|
1 |
|
if (!is_string($projectDir)) { |
54
|
|
|
throw new \RuntimeException('kernel.project_dir is not a string'); |
55
|
|
|
} |
56
|
|
|
|
57
|
1 |
|
$filePath = $projectDir.'/public/docs/old_metrics/index.html'; |
58
|
|
|
|
59
|
1 |
|
return new BinaryFileResponse($filePath); |
60
|
|
|
} |
61
|
|
|
|
62
|
1 |
|
#[Route('/docs/new_metrics/index', name: 'new_metrics')] |
63
|
|
|
public function newMetrics(): Response |
64
|
|
|
{ |
65
|
1 |
|
$projectDir = $this->getParameter('kernel.project_dir'); |
66
|
|
|
|
67
|
1 |
|
if (!is_string($projectDir)) { |
68
|
|
|
throw new \RuntimeException('kernel.project_dir is not a string'); |
69
|
|
|
} |
70
|
|
|
|
71
|
1 |
|
$filePath = $projectDir.'/public/docs/new_metrics/index.html'; |
72
|
|
|
|
73
|
1 |
|
return new BinaryFileResponse($filePath); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|