refactor: Form больше не наследует View

This commit is contained in:
origami11@yandex.ru 2025-04-03 19:59:56 +03:00
parent 2f8c788664
commit 6ef65fc826
4 changed files with 10 additions and 29 deletions

View file

@ -15,7 +15,7 @@ use ctiso\Form\Field,
/** /**
* Форма для ввода * Форма для ввода
*/ */
class Form extends View { class Form {
public $field = array(); //Поля формы public $field = array(); //Поля формы
public $fieldsets = array(); //Группы полей (fieldset). Некоторые поля могут не принадлежать никаким группам public $fieldsets = array(); //Группы полей (fieldset). Некоторые поля могут не принадлежать никаким группам
@ -28,7 +28,7 @@ class Form extends View {
public $_title = array(); public $_title = array();
public $alias = array(); public $alias = array();
public $constructor = array(); private $constructor = array();
/** /**
* Строим форму по ее структуре. Каждому типу соответствует определенный класс. * Строим форму по ее структуре. Каждому типу соответствует определенный класс.
@ -175,7 +175,7 @@ class Form extends View {
{ {
foreach ($schema as $key => $conv) { foreach ($schema as $key => $conv) {
list($value, $type) = $conv; list($value, $type) = $conv;
$this->field [$key]->setValue(call_user_func(['ctiso\\Primitive', 'from_' . $type], $data->$value)); $this->field [$key]->setValue(call_user_func([\ctiso\Primitive::class, 'from_' . $type], $data->$value));
} }
} }
@ -183,17 +183,7 @@ class Form extends View {
{ {
$this->field[$name]->setValue($value); $this->field[$name]->setValue($value);
} }
public function getSchema() {
return [
'field' => $this->field,
'fieldset' => $this->fieldsets,
'method' => $this->method,
'action' => $this->action,
'header' => $this->header
];
}
function execute() function execute()
{ {
return $this; return $this;

View file

@ -1,13 +1,8 @@
<?php <?php
/**
* @package system.view
*/
// View_Base + PHPTAL = View_Template (View_Composite)
namespace ctiso\View; namespace ctiso\View;
use ctiso\View\View, use ctiso\View\View,
PHPTAL; PHPTAL;
class Composite extends View class Composite extends View
{ {

View file

@ -1,10 +1,10 @@
<?php <?php
/**
* @package system.widgets
*/
namespace ctiso\View; namespace ctiso\View;
/**
* Постраничная навигация
*/
class Pages class Pages
{ {
static int $range = 5; static int $range = 5;
@ -54,6 +54,5 @@ class Pages
static function href($prefix, $x) { static function href($prefix, $x) {
return $prefix . $x; return $prefix . $x;
} }
} }

View file

@ -1,13 +1,10 @@
<?php <?php
// Класс отображения
// CompositeView !! Composite pattern
/**
* @package system.view
*/
namespace ctiso\View; namespace ctiso\View;
/**
* Шаблон для PHP
*/
class Plain extends \stdClass class Plain extends \stdClass
{ {
protected $document; protected $document;