1
|
|
|
<?php |
2
|
|
|
namespace app\controllers\examples; |
3
|
|
|
|
4
|
|
|
class Session extends \erdiko\controllers\Web |
5
|
|
|
{ |
6
|
|
|
use \erdiko\theme\traits\Controller; // Add theme engine suport (for convenience) |
7
|
|
|
|
8
|
|
|
public function get($request, $response, $args) |
9
|
|
|
{ |
10
|
|
|
// $this->container->logger->debug("examples"); |
|
|
|
|
11
|
|
|
$view = 'examples/list.html'; |
12
|
|
|
|
13
|
|
|
// Get erdiko config, this gets application.json and loads the theme specified |
14
|
|
|
// $themeData = \erdiko\theme\Config::get(); |
|
|
|
|
15
|
|
|
$themeData['theme'] = \erdiko\theme\Config::get($this->container->get('settings')['theme']); |
|
|
|
|
16
|
|
|
// $themeData['args'] = $args; // optional |
|
|
|
|
17
|
|
|
|
18
|
|
|
$themeData['page'] = [ |
19
|
|
|
'title' => "Erdiko Web Example", |
20
|
|
|
'hello' => "world" |
21
|
|
|
]; |
22
|
|
|
|
23
|
|
|
return $this->container->theme->render($response, $view, $themeData); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Test the session |
28
|
|
|
*/ |
29
|
|
View Code Duplication |
public function getSession($request, $response, $args) |
|
|
|
|
30
|
|
|
{ |
31
|
|
|
$this->getThemeEngine(); |
32
|
|
|
$this->theme->title = "Session Test"; |
33
|
|
|
|
34
|
|
|
$value = (isset($_GET["index"])) ? $_GET["index"] : \erdiko\session\Session::get('index'); |
|
|
|
|
35
|
|
|
\erdiko\session\Session::set('index', $value); |
36
|
|
|
|
37
|
|
|
// $this->container->logger->debug("session::index = ".\erdiko\session\Session::get('index')); |
|
|
|
|
38
|
|
|
$this->theme->description = "Session value: ".\erdiko\session\Session::get('index'); |
|
|
|
|
39
|
|
|
|
40
|
|
|
return $this->render($response, null, $theme); |
|
|
|
|
41
|
|
|
} |
42
|
|
|
|
43
|
|
View Code Duplication |
public function getFlash($request, $response, $args) |
|
|
|
|
44
|
|
|
{ |
45
|
|
|
$view = 'page.html'; |
46
|
|
|
|
47
|
|
|
// Add some flash messages |
48
|
|
|
$this->container->flash->addMessage('success', 'This is a success message'); |
49
|
|
|
$this->container->flash->addMessage('info', 'This is an info message'); |
50
|
|
|
$this->container->flash->addMessage('warning', 'This is a warning message'); |
51
|
|
|
$this->container->flash->addMessage('danger', 'This is a danger (error) message'); |
52
|
|
|
|
53
|
|
|
// Get erdiko config, this gets application.json and loads the theme specified |
54
|
|
|
$themeData['theme'] = \erdiko\theme\Config::get($this->container->get('settings')['theme']); |
|
|
|
|
55
|
|
|
$themeData['args'] = $args; |
56
|
|
|
$themeData['page'] = [ |
57
|
|
|
'title' => "Flash Message Example" |
58
|
|
|
]; |
59
|
|
|
|
60
|
|
|
return $this->container->theme->render($response, $view, $themeData); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
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.