File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 6
6
use Mvc5 \Plugin \Callback ;
7
7
use Mvc5 \Session \SessionMessages ;
8
8
use Mvc5 \Service \Context ;
9
+ use Plugin \Page ;
9
10
use Plugin \Redirect ;
10
11
use Psr \Http \Message \ResponseInterface as Response ;
11
12
use Valar \RedirectResponse ;
91
92
'path ' => '/redirect ' ,
92
93
'controller ' => new Redirect ('/home ' ),
93
94
],
95
+ 'page ' => [
96
+ 'path ' => '/page ' ,
97
+ 'controller ' => new Page ('home/index ' , ['title ' => 'Demo Page ' ]),
98
+ ],
94
99
'app ' => [
95
100
/*'host' => 'nexus.app.dev',
96
101
'port' => 8000,*/
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+
6
+ namespace Plugin ;
7
+
8
+ use Mvc5 \Arg ;
9
+ use Mvc5 \Http \Request ;
10
+ use Mvc5 \Plugin \Call ;
11
+ use Mvc5 \Plugin \Callback ;
12
+
13
+ class Page
14
+ extends Call
15
+ {
16
+ /**
17
+ * @param string $template
18
+ * @param array $vars
19
+ */
20
+ function __construct (string $ template , array $ vars = [])
21
+ {
22
+ parent ::__construct ([$ this , '__invoke ' ], [$ template , $ vars ]);
23
+ }
24
+
25
+ /**
26
+ * @param string $template
27
+ * @param array $vars
28
+ * @return Callback
29
+ */
30
+ function __invoke (string $ template , array $ vars )
31
+ {
32
+ return new Callback (function (Request $ request ) use ($ template , $ vars ) {
33
+ return $ this ->plugin (Arg::VIEW_MODEL , [$ template , $ vars + [Arg::REQUEST => $ request ]]);
34
+ });
35
+ }
36
+ }
Original file line number Diff line number Diff line change 7
7
8
8
?>
9
9
<div class="jumbotron">
10
- <h1><a href="<?= $ this ->url ('home ' ) ?> "><?= $ this ->title () ?> </a></h1>
10
+ <h1><a href="<?= $ this ->url ('home ' ) ?> "><?= $ this ->title ?> </a></h1>
11
11
<p class="lead"><?= $ this ['message ' ] ?> </p>
12
12
<pre><?= __FILE__ ; ?> </pre>
13
13
<div id="ajax-result"></div>
14
14
<p>
15
15
<a class="btn btn-primary btn-lg" href="#" role="button" onclick="return info();">Info</a>
16
16
<a class="btn btn-primary btn-lg" href="#" role="button" onclick="return about();">About</a>
17
17
<a class="btn btn-primary btn-lg" href="#" role="button" onclick="return demo();">Demo</a>
18
+ <a class="btn btn-primary btn-lg" href="/page" role="button">Page</a>
18
19
<a class="btn btn-primary btn-lg" href="/redirect" role="button">Redirect</a>
19
20
</p>
20
21
</div>
You can’t perform that action at this time.
0 commit comments