Partial to lib

This commit is contained in:
JonatanRek
2020-04-28 11:44:35 +02:00
parent 2560800efb
commit a3d911d3ec

34
library/Partial.php Normal file
View File

@@ -0,0 +1,34 @@
<?php
class Partial{
private $assignedValues = [];
private $partBuffer;
private $path;
private $debug;
function __construct($path = "", $debug = false) {
$this->debug = $debug;
if (!empty('../app/views/templates/part/' . $path . '.phtml') && file_exists('../app/views/templates/part/' . $path . '.phtml')) {
$this->path = $path;
} else {
echo '<pre>';
echo 'PHTML: Parial File ' . $path . ' not found';
echo '</pre>';
die();
}
}
function prepare($searchS, $repleaceS) {
if (!empty($searchS)) {
$this->assignedValues[strtoupper($searchS)] = $repleaceS;
}
echo ($this->debug == true ? var_dump($this->assignedValues) : '');
}
function render() {
if (!empty($this->assignedValues)){
extract($this->assignedValues);
}
require('../app/views/templates/part/' . $this->path . '.phtml');
}
}