diff --git a/lib/flexi/PhpTemplate.php b/lib/flexi/PhpTemplate.php index 8110b50dff5cdea1be346a51c8e61ba8c156ceb5..4eb0da131141e8a3ddb587d885183ab39c49e9d9 100644 --- a/lib/flexi/PhpTemplate.php +++ b/lib/flexi/PhpTemplate.php @@ -17,20 +17,15 @@ class PhpTemplate extends Template * @return string A string representing the rendered presentation. * @throws TemplateNotFoundException */ - public function _render(): string + protected function _render(): string { extract($this->get_attributes()); # include template, parse it and get output - try { - ob_start(); - require $this->template; - $content_for_layout = ob_get_contents(); - } catch (\Error $e) { - throw new TemplateNotFoundException(previous: $e); - } finally { - ob_end_clean(); - } + ob_start(); + require $this->template; + $content_for_layout = ob_get_contents(); + ob_end_clean(); # include layout, parse it and get output if (isset($this->layout)) { diff --git a/lib/flexi/Template.php b/lib/flexi/Template.php index d5c0310c77b521c9978196c885a416024c293e94..44eefbe457a765c2b14c7326c4bbca1138b36eda 100644 --- a/lib/flexi/Template.php +++ b/lib/flexi/Template.php @@ -18,7 +18,7 @@ abstract class Template * * @return string A string representing the rendered presentation. */ - abstract public function _render(): string; + abstract protected function _render(): string; protected array $attributes = []; protected Template|null $layout = null; diff --git a/tests/unit/lib/flexi/FactoryTest.php b/tests/unit/lib/flexi/FactoryTest.php index 2df9f6aaae74177281b5f14988dfd39517c14f8c..f8b9b8773a404b8ab9a500db47898a1e4b364a43 100644 --- a/tests/unit/lib/flexi/FactoryTest.php +++ b/tests/unit/lib/flexi/FactoryTest.php @@ -108,7 +108,7 @@ final class FactoryTestCase extends \Codeception\Test\Unit public function testShouldRespondToAddedHandlers() { $handler = new class('', $this->factory) extends Flexi\Template { - public function _render(): string + protected function _render(): string { return ''; }