-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.php
executable file
·46 lines (38 loc) · 961 Bytes
/
view.php
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
<?php
namespace PMVC\PlugIn\view;
use PMVC as p;
use SplSubject;
use DomainException;
${_INIT_CONFIG}[_CLASS] = __NAMESPACE__.'\view';
class view extends p\PlugIn
{
private $_view;
public function init()
{
$this->_change(p\getOption(_VIEW_ENGINE));
p\callPlugin(
'dispatcher',
'attach',
[
$this,
'SetConfig__view_engine_',
]
);
}
public function onSetConfig__view_engine_($subject)
{
$this->_change(p\getOption(_VIEW_ENGINE));
}
private function _change($viewEngine)
{
$this->_view = 'view_'.$viewEngine;
if (!p\exists($this->_view, 'plug')) {
throw new DomainException('View engine not eixis.['.$this->_view.']');
}
}
public function update(SplSubject $SplSubject=null)
{
parent::update($SplSubject);
return p\plug($this->_view);
}
}