Improved recursion fix

This commit is contained in:
Dennis Eichhorn 2017-09-06 14:54:13 +02:00
parent ddd0cea898
commit 34021f1cd5

View File

@ -237,6 +237,9 @@ abstract class ViewAbstract implements \Serializable
*/ */
public function render(...$data) public function render(...$data)
{ {
$ob = '';
try {
$path = __DIR__ . '/../..' . $this->template . '.tpl.php'; $path = __DIR__ . '/../..' . $this->template . '.tpl.php';
if (!file_exists($path)) { if (!file_exists($path)) {
@ -245,15 +248,18 @@ abstract class ViewAbstract implements \Serializable
ob_start(); ob_start();
/** @noinspection PhpIncludeInspection */ /** @noinspection PhpIncludeInspection */
$tpl = include $path; $data = include $path;
$ob = ob_get_clean(); $ob = ob_get_clean();
if (is_array($tpl)) { if (is_array($data)) {
return $tpl; return $data;
} }
} catch(\Throwable $e) {
$ob = '';
} finally {
return $ob; return $ob;
} }
}
/** /**
* Unserialize view. * Unserialize view.