Регистр файлов
This commit is contained in:
parent
4fd0187ea6
commit
c8958cbee0
83 changed files with 25 additions and 53 deletions
40
src/View/View.php
Normal file
40
src/View/View.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
// Класс отображения
|
||||
// CompositeView !! Composite pattern
|
||||
|
||||
class View
|
||||
{
|
||||
protected $document;
|
||||
protected $values;
|
||||
|
||||
public function __construct ($document)
|
||||
{
|
||||
$this->document = $document;
|
||||
}
|
||||
|
||||
public function set($key, $value)
|
||||
{
|
||||
$this->values[$key] = $value;
|
||||
}
|
||||
|
||||
public function __set($key, $value)
|
||||
{
|
||||
$this->set($key, $value);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$result = $this->values;
|
||||
return self::getTemplateContent ($this->document, $result);
|
||||
}
|
||||
|
||||
static function getTemplateContent($document, $result)
|
||||
{
|
||||
ob_start ();
|
||||
include ($document);
|
||||
$result = ob_get_contents ();
|
||||
ob_clean ();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue