1
|
|
|
<?php |
2
|
|
|
namespace app\controllers; |
3
|
|
|
|
4
|
|
|
class Examples extends \erdiko\controllers\Web |
5
|
|
|
{ |
6
|
|
View Code Duplication |
public function get($request, $response, $args) |
|
|
|
|
7
|
|
|
{ |
8
|
|
|
$view = 'examples/list.html'; |
9
|
|
|
|
10
|
|
|
// Get erdiko config, this gets application.json and loads the theme specified |
11
|
|
|
$themeData = \erdiko\theme\Config::get(); |
12
|
|
|
$themeData['args'] = $args; // optional |
13
|
|
|
$themeData['page'] = [ |
14
|
|
|
'title' => "Erdiko Web Example" |
15
|
|
|
]; |
16
|
|
|
|
17
|
|
|
return $this->container->theme->render($response, $view, $themeData); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
View Code Duplication |
public function getJohn($request, $response, $args) |
|
|
|
|
21
|
|
|
{ |
22
|
|
|
$view = 'pages/example.html'; |
23
|
|
|
|
24
|
|
|
// Get erdiko config, this gets application.json and loads the theme specified |
25
|
|
|
$themeData = \erdiko\theme\Config::get(); |
26
|
|
|
$themeData['args'] = $args; // optional |
27
|
|
|
$themeData['page'] = [ |
28
|
|
|
'title' => "Erdiko Web Example" |
29
|
|
|
]; |
30
|
|
|
|
31
|
|
|
return $this->container->theme->render($response, $view, $themeData); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
View Code Duplication |
public function getMarkup($request, $response, $args) |
|
|
|
|
35
|
|
|
{ |
36
|
|
|
$view = 'examples/markup.html'; |
37
|
|
|
|
38
|
|
|
// Get erdiko config, this gets application.json and loads the theme specified |
39
|
|
|
$themeData = \erdiko\theme\Config::get(); |
40
|
|
|
$themeData['args'] = $args; // optional |
41
|
|
|
$themeData['page'] = [ |
42
|
|
|
'title' => "Markup Example" |
43
|
|
|
]; |
44
|
|
|
|
45
|
|
|
return $this->container->theme->render($response, $view, $themeData); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function getGrid($request, $response, $args) |
49
|
|
|
{ |
50
|
|
|
$this->container->logger->debug("/controller"); |
51
|
|
|
$view = 'examples/grid.html'; |
52
|
|
|
|
53
|
|
|
// Get erdiko config, this gets application.json and loads the theme specified |
54
|
|
|
$themeData = \erdiko\theme\Config::get(); |
55
|
|
|
// $this->container->logger->debug("config: ".print_r($config, true)); |
|
|
|
|
56
|
|
|
|
57
|
|
|
$item = [ |
58
|
|
|
'url' => "#", |
59
|
|
|
'image' => "/images/grid-item.png", |
60
|
|
|
'name' => "Item" |
61
|
|
|
]; |
62
|
|
|
$items = array(); |
63
|
|
|
$max = (int)$args['param']; |
64
|
|
|
$this->container->logger->debug("param: ".$max); |
65
|
|
|
|
66
|
|
View Code Duplication |
for($i = 0; $i < $max; $i++) { |
|
|
|
|
67
|
|
|
$item['name'] = "Item $i"; |
68
|
|
|
$items[] = $item; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
$themeData['args'] = $args; |
72
|
|
|
$themeData['page'] = [ |
73
|
|
|
'title' => "Grid Example", |
74
|
|
|
'items' => $items |
75
|
|
|
]; |
76
|
|
|
|
77
|
|
|
return $this->container->theme->render($response, $view, $themeData); |
78
|
|
|
} |
79
|
|
|
} |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.