-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathView.php
More file actions
109 lines (91 loc) · 1.97 KB
/
Copy pathView.php
File metadata and controls
109 lines (91 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
namespace Steel;
use Steel\Injectors\View\Template as TemplateInjector;
use Steel\Injectors\View\Data as DataInjector;
use Steel\Injectors\Config as ConfigInjector;
use Steel\Injectors\Renderer as RendererInjector;
/**
*/class View
{
use TemplateInjector;
use DataInjector;
use ConfigInjector;
use RendererInjector;
/**
* @var Interfaces\Renderer
*/
protected $renderer;
/**
* @var mixed
*/
protected $template;
/**
* @var mixed
*/
protected $data;
/**
* @var string
*/
protected $name;
/**
* @var Interfaces\Config
*/
protected $config;
/**
* @param $name
*/
protected function __construct($name)
{
$this->config = $this->getConfig()->get();
$this->name = stripslashes(basename($name));
$this->setTemplate($name);
$this->renderer = $this->getRenderer($this->config->renderer);
$this->data = $this->getData($this->name, $this->renderer->getDataType());
$this->baseTemplate = $this->config->baseTemplate;
}
/**
* Set the template name we will be using
*
* @param string $name
* @return void
*/
public function setTemplate($name)
{
$this->template = str_replace('\\', '/', $name);
}
/**
* @param $name
* @return View
*/
public static function create($name)
{
return new self( $name );
}
/**
* @param Interfaces\Renderer $renderer
*/
public function setRenderer(Interfaces\Renderer $renderer)
{
$this->renderer = $renderer;
}
/**
* @param $name
* @param $value
*/
public function attach($name, $value)
{
$this->data->setData($name, $value);
}
/**
*/
public function render()
{
return $this->renderer->render($this->data, $this->template);
}
/**
*/
public function output()
{
echo $this->render();
}
}