Skip to content
This repository was archived by the owner on Jan 23, 2019. It is now read-only.

Commit 21ce8bb

Browse files
committed
some update
1 parent 3cbf7a7 commit 21ce8bb

File tree

4 files changed

+73
-6
lines changed

4 files changed

+73
-6
lines changed

src/Utils/Environment.php renamed to src/Web/Environment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
* File: Environment.php
88
*/
99

10-
namespace Inhere\Library\Utils;
10+
namespace Inhere\Library\Web;
1111

1212
use Inhere\Library\Collections\SimpleCollection;
1313

1414
/**
1515
* 环境信息
1616
* Class Environment
17-
* @package Inhere\LibraryPlus\Utils
17+
* @package Inhere\Library\Web
1818
*/
1919
class Environment extends SimpleCollection
2020
{

src/Components/Session.php renamed to src/Web/Session.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
* Time: 下午11:14
77
*/
88

9-
namespace Inhere\Library\Components;
9+
namespace Inhere\Library\Web;
1010

1111
use Inhere\Library\Collections\SimpleCollection;
1212

1313
/**
1414
* Class Session
15-
* @package Inhere\Library\Utils
15+
* @package Inhere\Library\Web
1616
*/
1717
class Session extends SimpleCollection
1818
{

src/Components/ViewRenderer.php renamed to src/Web/ViewRenderer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
* Time: 17:31
77
*/
88

9-
namespace Inhere\Library\Components;
9+
namespace Inhere\Library\Web;
1010

1111
use 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
*/
1818
class ViewRenderer
1919
{

src/Web/ViewRendererTrait.php

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
}

0 commit comments

Comments
 (0)