feat: FakeTemplate -> JsonView
This commit is contained in:
parent
18cc1cad01
commit
5170ed8ed5
2 changed files with 12 additions and 4 deletions
|
|
@ -16,7 +16,7 @@ use ctiso\Controller\SiteInterface;
|
||||||
use ctiso\Database\PDOStatement;
|
use ctiso\Database\PDOStatement;
|
||||||
use PHPTAL;
|
use PHPTAL;
|
||||||
use PHPTAL_PreFilter_Normalize;
|
use PHPTAL_PreFilter_Normalize;
|
||||||
use ctiso\View\FakeTemplate;
|
use ctiso\View\JsonView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Класс компонента
|
* Класс компонента
|
||||||
|
|
@ -117,12 +117,12 @@ class Component
|
||||||
/**
|
/**
|
||||||
* Получить шаблон
|
* Получить шаблон
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return PHPTAL|FakeTemplate
|
* @return PHPTAL|JsonView
|
||||||
*/
|
*/
|
||||||
public function getView($name)
|
public function getView($name)
|
||||||
{
|
{
|
||||||
if ($this->output === 'json') {
|
if ($this->output === 'json') {
|
||||||
return new FakeTemplate($name);
|
return new JsonView($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Registry $config */
|
/** @var Registry $config */
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace ctiso\View;
|
namespace ctiso\View;
|
||||||
|
|
||||||
class FakeTemplate extends \stdClass {
|
class JsonView extends \stdClass {
|
||||||
/** @var array */
|
/** @var array */
|
||||||
public $_data = [];
|
public $_data = [];
|
||||||
/** @var string */
|
/** @var string */
|
||||||
|
|
@ -15,6 +15,14 @@ class FakeTemplate extends \stdClass {
|
||||||
$this->_name = $name;
|
$this->_name = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $key
|
||||||
|
* @param mixed $value
|
||||||
|
*/
|
||||||
|
function set($key, $value): void {
|
||||||
|
$this->_data[$key] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
Loading…
Add table
Add a link
Reference in a new issue