optimize views

This commit is contained in:
Dennis Eichhorn 2022-05-01 22:05:01 +02:00
parent 35d13cd7db
commit 8c865bb0aa
2 changed files with 9 additions and 4 deletions

View File

@ -77,7 +77,7 @@ class View extends ViewAbstract
* @var null|string * @var null|string
* @since 1.0.0 * @since 1.0.0
*/ */
protected ?string $theme = null; public ?string $theme = null;
/** /**
* Module name. * Module name.
@ -85,7 +85,7 @@ class View extends ViewAbstract
* @var null|string * @var null|string
* @since 1.0.0 * @since 1.0.0
*/ */
protected ?string $module = null; public ?string $module = null;
/** /**
* Constructor. * Constructor.

View File

@ -32,7 +32,7 @@ abstract class ViewAbstract implements RenderableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private const BASE_PATH = __DIR__ . '/../..'; protected const BASE_PATH = __DIR__ . '/../..';
/** /**
* Output is buffered * Output is buffered
@ -261,6 +261,11 @@ abstract class ViewAbstract implements RenderableInterface
* @since 1.0.0 * @since 1.0.0
*/ */
public function render(...$data) : string public function render(...$data) : string
{
return $this->renderTemplate($this->template, ...$data);
}
protected function renderTemplate(string $template, ...$data) : string
{ {
$ob = ''; $ob = '';
@ -269,7 +274,7 @@ abstract class ViewAbstract implements RenderableInterface
\ob_start(); \ob_start();
} }
$path = $this->template; $path = $template;
if (!\is_file($path)) { if (!\is_file($path)) {
return ''; return '';
} }