This repository was archived by the owner on Jan 23, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +73
-6
lines changed Expand file tree Collapse file tree 4 files changed +73
-6
lines changed Original file line number Diff line number Diff line change 7
7
* File: Environment.php
8
8
*/
9
9
10
- namespace Inhere \Library \Utils ;
10
+ namespace Inhere \Library \Web ;
11
11
12
12
use Inhere \Library \Collections \SimpleCollection ;
13
13
14
14
/**
15
15
* 环境信息
16
16
* Class Environment
17
- * @package Inhere\LibraryPlus\Utils
17
+ * @package Inhere\Library\Web
18
18
*/
19
19
class Environment extends SimpleCollection
20
20
{
Original file line number Diff line number Diff line change 6
6
* Time: 下午11:14
7
7
*/
8
8
9
- namespace Inhere \Library \Components ;
9
+ namespace Inhere \Library \Web ;
10
10
11
11
use Inhere \Library \Collections \SimpleCollection ;
12
12
13
13
/**
14
14
* Class Session
15
- * @package Inhere\Library\Utils
15
+ * @package Inhere\Library\Web
16
16
*/
17
17
class Session extends SimpleCollection
18
18
{
Original file line number Diff line number Diff line change 6
6
* Time: 17:31
7
7
*/
8
8
9
- namespace Inhere \Library \Components ;
9
+ namespace Inhere \Library \Web ;
10
10
11
11
use Inhere \Library \Files \File ;
12
12
13
13
/**
14
14
* Class ViewRenderer
15
15
* Render PHP view scripts into a PSR-7 Response object
16
- * @package Inhere\Library\Components
16
+ * @package Inhere\Library\Web
17
17
*/
18
18
class ViewRenderer
19
19
{
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: inhere
5
+ * Date: 2017-10-19
6
+ * Time: 9:12
7
+ */
8
+
9
+ namespace Inhere \Library \Web ;
10
+
11
+ /**
12
+ * Trait ViewRendererTrait
13
+ * @package Inhere\Library\Web
14
+ */
15
+ trait ViewRendererTrait
16
+ {
17
+ /**
18
+ * getRenderer
19
+ * @return ViewRenderer
20
+ */
21
+ abstract public function getRenderer ();
22
+
23
+ /**
24
+ * @param string $view
25
+ * @return string
26
+ */
27
+ protected function resolveView (string $ view )
28
+ {
29
+ return $ view ;
30
+ }
31
+
32
+ /*********************************************************************************
33
+ * view method
34
+ *********************************************************************************/
35
+
36
+ /**
37
+ * @param string $view
38
+ * @param array $data
39
+ * @param null|string $layout
40
+ * @return string
41
+ */
42
+ public function render (string $ view , array $ data = [], $ layout = null )
43
+ {
44
+ return $ this ->getRenderer ()->render ($ this ->resolveView ($ view ), $ data , $ layout );
45
+ }
46
+
47
+ /**
48
+ * @param string $view
49
+ * @param array $data
50
+ * @return string
51
+ */
52
+ public function renderPartial ($ view , array $ data = [])
53
+ {
54
+ return $ this ->getRenderer ()->fetch ($ this ->resolveView ($ view ), $ data );
55
+ }
56
+
57
+ /**
58
+ * @param string $string
59
+ * @param array $data
60
+ * @return string
61
+ */
62
+ public function renderContent ($ string , array $ data = [])
63
+ {
64
+ return $ this ->getRenderer ()->renderContent ($ string , $ data );
65
+ }
66
+
67
+ }
You can’t perform that action at this time.
0 commit comments