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 77 * File: Environment.php
88 */
99
10- namespace Inhere \Library \Utils ;
10+ namespace Inhere \Library \Web ;
1111
1212use Inhere \Library \Collections \SimpleCollection ;
1313
1414/**
1515 * 环境信息
1616 * Class Environment
17- * @package Inhere\LibraryPlus\Utils
17+ * @package Inhere\Library\Web
1818 */
1919class Environment extends SimpleCollection
2020{
Original file line number Diff line number Diff line change 66 * Time: 下午11:14
77 */
88
9- namespace Inhere \Library \Components ;
9+ namespace Inhere \Library \Web ;
1010
1111use Inhere \Library \Collections \SimpleCollection ;
1212
1313/**
1414 * Class Session
15- * @package Inhere\Library\Utils
15+ * @package Inhere\Library\Web
1616 */
1717class Session extends SimpleCollection
1818{
Original file line number Diff line number Diff line change 66 * Time: 17:31
77 */
88
9- namespace Inhere \Library \Components ;
9+ namespace Inhere \Library \Web ;
1010
1111use Inhere \Library \Files \File ;
1212
1313/**
1414 * Class ViewRenderer
1515 * Render PHP view scripts into a PSR-7 Response object
16- * @package Inhere\Library\Components
16+ * @package Inhere\Library\Web
1717 */
1818class ViewRenderer
1919{
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