From 5170ed8ed5a78c05a0f575a011a830b092b8a827 Mon Sep 17 00:00:00 2001 From: "origami11@yandex.ru" Date: Wed, 3 Dec 2025 17:12:40 +0300 Subject: [PATCH] feat: FakeTemplate -> JsonView --- src/Controller/Component.php | 6 +++--- src/View/{FakeTemplate.php => JsonView.php} | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) rename src/View/{FakeTemplate.php => JsonView.php} (73%) diff --git a/src/Controller/Component.php b/src/Controller/Component.php index a6916a5..fbf04b7 100644 --- a/src/Controller/Component.php +++ b/src/Controller/Component.php @@ -16,7 +16,7 @@ use ctiso\Controller\SiteInterface; use ctiso\Database\PDOStatement; use PHPTAL; use PHPTAL_PreFilter_Normalize; -use ctiso\View\FakeTemplate; +use ctiso\View\JsonView; /** * Класс компонента @@ -117,12 +117,12 @@ class Component /** * Получить шаблон * @param string $name - * @return PHPTAL|FakeTemplate + * @return PHPTAL|JsonView */ public function getView($name) { if ($this->output === 'json') { - return new FakeTemplate($name); + return new JsonView($name); } /** @var Registry $config */ diff --git a/src/View/FakeTemplate.php b/src/View/JsonView.php similarity index 73% rename from src/View/FakeTemplate.php rename to src/View/JsonView.php index 223fa46..3ba8fd4 100644 --- a/src/View/FakeTemplate.php +++ b/src/View/JsonView.php @@ -2,7 +2,7 @@ namespace ctiso\View; -class FakeTemplate extends \stdClass { +class JsonView extends \stdClass { /** @var array */ public $_data = []; /** @var string */ @@ -15,6 +15,14 @@ class FakeTemplate extends \stdClass { $this->_name = $name; } + /** + * @param string $key + * @param mixed $value + */ + function set($key, $value): void { + $this->_data[$key] = $value; + } + /** * @param string $key * @param mixed $value