1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Phase\TakeATicketBundle\Controller; |
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
6
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
7
|
|
|
|
8
|
|
|
class DefaultController extends BaseController |
9
|
|
|
{ |
10
|
|
|
public function indexAction() |
11
|
|
|
{ |
12
|
|
|
$viewParams = $this->defaultViewParams(); |
13
|
|
|
$viewParams['freeze'] = $this->getDataStore()->getSetting('freeze'); |
14
|
|
|
$viewParams['freezeMessage'] = $this->getDataStore()->getSetting('freezeMessage'); |
15
|
|
|
|
16
|
|
|
// replace this example code with whatever you need |
17
|
|
|
return $this->render('default/upcoming.html.twig', $viewParams); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function songSearchAction() |
21
|
|
|
{ |
22
|
|
|
$viewParams = $this->defaultViewParams(); |
23
|
|
|
$viewParams['freeze'] = $this->getDataStore()->getSetting('freeze'); |
24
|
|
|
return $this->render('default/songSearch.html.twig', $viewParams); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @return array |
29
|
|
|
*/ |
30
|
|
|
protected function defaultViewParams() |
31
|
|
|
{ |
32
|
|
|
//$protocol = $_SERVER['HTTPS'] ? 'https' : 'http'; |
|
|
|
|
33
|
|
|
$protocol = 'http'; // $_SERVER['HTTPS'] ? 'https' : 'http'; |
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @noinspection RealpathInSteamContextInspection |
36
|
|
|
*/ |
37
|
|
|
$viewParams = [ |
38
|
|
|
//'serverInfo' => $protocol . '://' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT'] . '/', |
|
|
|
|
39
|
|
|
'serverInfo' => $protocol.'://127.0.0.1:8000/', //FIXME get server name (from config if not in request?) |
40
|
|
|
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..'), |
41
|
|
|
]; |
42
|
|
|
$viewParams['displayOptions'] = $this->getDisplayOptions(); |
43
|
|
|
|
44
|
|
|
return $viewParams; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
View Code Duplication |
public function announceAction($section) |
|
|
|
|
48
|
|
|
{ |
49
|
|
|
$rootDir = realpath(__DIR__.'/../../../../'); |
50
|
|
|
$announceDir = $rootDir.'/docs/announcements'; |
51
|
|
|
|
52
|
|
|
if (!preg_match('/^\w+$/', $section)) { |
53
|
|
|
throw new NotFoundHttpException(); // don't give access to anything but plain names |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
$candidateFile = $announceDir.'/'.$section.'.md'; |
57
|
|
|
|
58
|
|
|
if (!file_exists($candidateFile)) { |
59
|
|
|
throw new NotFoundHttpException(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
$markdown = file_get_contents($candidateFile); |
63
|
|
|
|
64
|
|
|
return $this->render( |
65
|
|
|
':default:announce.html.twig', |
66
|
|
|
[ |
67
|
|
|
'announcement' => $markdown, |
68
|
|
|
'messageClass' => $section, |
69
|
|
|
'displayOptions' => $this->getDisplayOptions(), |
70
|
|
|
] |
71
|
|
|
); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.