refactor: Упрощение контроллера
This commit is contained in:
parent
b20ea0e7dc
commit
0473d410d1
1 changed files with 2 additions and 84 deletions
|
|
@ -47,16 +47,10 @@ class Action implements ActionInterface
|
|||
public $part = null;
|
||||
|
||||
/** @var \ctiso\Registry Ссылка на настройки */
|
||||
public $config;
|
||||
public $config;
|
||||
/** @var \ctiso\Role\User Обьект пользователя */
|
||||
public $user;
|
||||
|
||||
/** @var \ctiso\View\View Для Widgets */
|
||||
public $view = null;
|
||||
|
||||
public array $childNodes = [];
|
||||
public array $ctrlValues = [];
|
||||
public array $childViews = [];
|
||||
|
||||
function __construct() {
|
||||
$this->part = new Url();
|
||||
|
|
@ -216,11 +210,7 @@ class Action implements ActionInterface
|
|||
public function execute(HttpRequest $request)
|
||||
{
|
||||
$result = $this->preProcess($request);
|
||||
if (!empty($result)) {
|
||||
$this->view = $result;
|
||||
}
|
||||
$text = $this->render();
|
||||
return $text;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -352,78 +342,6 @@ class Action implements ActionInterface
|
|||
return $result->export();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setView($name): void
|
||||
{
|
||||
$this->view = $this->getView($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Установка заголовка для отображения
|
||||
* @param string $title
|
||||
*/
|
||||
public function setTitle($title): void
|
||||
{
|
||||
$this->view->setTitle($title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Добавление widget к отображению
|
||||
* @param string $section
|
||||
* @param View $node
|
||||
*/
|
||||
public function addChild($section, $node): void
|
||||
{
|
||||
$this->childNodes[$section] = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установка значения контроллера
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setValue($name, $value): void
|
||||
{
|
||||
$this->ctrlValues[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Добавление дочернего отображения к текущему отображению
|
||||
* @param string $section
|
||||
* @param View $node
|
||||
*/
|
||||
public function addView($section, $node): void
|
||||
{
|
||||
$this->childViews[$section] = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Генерация содержания
|
||||
* Путаница c execute и render
|
||||
* @return View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$view = $this->view;
|
||||
if ($view instanceof View) {
|
||||
$this->view->assignValues($this->ctrlValues);
|
||||
|
||||
/** @var ?Composite $node */
|
||||
$node = null;
|
||||
foreach ($this->childNodes as $name => $node) {
|
||||
$node->make($this);
|
||||
$this->view->setView($name, $node->view);
|
||||
}
|
||||
|
||||
foreach ($this->childViews as $name => $node) {
|
||||
$this->view->setView($name, $node);
|
||||
}
|
||||
}
|
||||
return $this->view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установка идентификатора страницы
|
||||
* @return int
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue