fix Validator
This commit is contained in:
parent
28429039a4
commit
526262c80b
9 changed files with 38 additions and 39 deletions
|
|
@ -26,6 +26,7 @@ class Action
|
||||||
|
|
||||||
// Параметры устанавливаются при создании контроллера
|
// Параметры устанавливаются при создании контроллера
|
||||||
public $name = ''; // Имя модуля
|
public $name = ''; // Имя модуля
|
||||||
|
public $front;
|
||||||
|
|
||||||
public $modulePath = null; // Путь к модулю
|
public $modulePath = null; // Путь к модулю
|
||||||
public $moduleTitle = '';
|
public $moduleTitle = '';
|
||||||
|
|
|
||||||
|
|
@ -171,8 +171,9 @@ class Component
|
||||||
*/
|
*/
|
||||||
public function getModel($name)
|
public function getModel($name)
|
||||||
{
|
{
|
||||||
$modelName = "Mapper_" . $name;
|
$modelName = "App\\Mapper\\" . $name;
|
||||||
$model = new $modelName();
|
$model = new $modelName();
|
||||||
|
$model->config = $this->config;
|
||||||
$model->db = $this->db;
|
$model->db = $this->db;
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
|
|
@ -260,7 +261,7 @@ class Component
|
||||||
} else {
|
} else {
|
||||||
$component = new $className();
|
$component = new $className();
|
||||||
|
|
||||||
$template = $component->getTemplateName($registry);
|
$template = $component->getTemplateName($site->config);
|
||||||
|
|
||||||
$component->viewPath = array(
|
$component->viewPath = array(
|
||||||
// Сначало ищем локально
|
// Сначало ищем локально
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@ class Front extends Action
|
||||||
$module->config = $this->config;
|
$module->config = $this->config;
|
||||||
$module->db = $this->db;
|
$module->db = $this->db;
|
||||||
$module->user = $this->user;
|
$module->user = $this->user;
|
||||||
|
$module->front = $this;
|
||||||
// Ведение лога
|
// Ведение лога
|
||||||
$logger = new ActionLogger($module, $logPath, $this->user);
|
$logger = new ActionLogger($module, $logPath, $this->user);
|
||||||
$logger->before = $this->loadSettings(Path::join($modPath, 'filter', 'logger.php'));
|
$logger->before = $this->loadSettings(Path::join($modPath, 'filter', 'logger.php'));
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
namespace ctiso\Controller;
|
namespace ctiso\Controller;
|
||||||
|
|
||||||
interface SiteInterface {
|
interface SiteInterface {
|
||||||
|
function getResource();
|
||||||
function loadComponent($expression);
|
function loadComponent($expression);
|
||||||
function getDatabase();
|
function getDatabase();
|
||||||
function getConfig();
|
function getConfig();
|
||||||
|
|
|
||||||
|
|
@ -48,20 +48,4 @@ class Registry {
|
||||||
function set($ns, $key, $value) {
|
function set($ns, $key, $value) {
|
||||||
$this->namespace[$ns]['data'][$key] = $value;
|
$this->namespace[$ns]['data'][$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Список модулей
|
|
||||||
*/
|
|
||||||
public function getModules()
|
|
||||||
{
|
|
||||||
return array_keys($this->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Проверка наличия модуля
|
|
||||||
*/
|
|
||||||
public function hasModule($name)
|
|
||||||
{
|
|
||||||
return isset($this->data[$name]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,11 +157,6 @@ class Settings
|
||||||
unset($data[$name]);
|
unset($data[$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOwner()
|
|
||||||
{
|
|
||||||
return array_keys($this->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Запись настроек в файл (Может переименовать в store)
|
* Запись настроек в файл (Может переименовать в store)
|
||||||
*
|
*
|
||||||
|
|
@ -195,4 +190,20 @@ class Settings
|
||||||
function import($data) {
|
function import($data) {
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Список модулей/ключей
|
||||||
|
*/
|
||||||
|
public function getKeys()
|
||||||
|
{
|
||||||
|
return array_keys($this->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Проверка наличия ключа
|
||||||
|
*/
|
||||||
|
public function hasKey($name)
|
||||||
|
{
|
||||||
|
return isset($this->data[$name]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ namespace ctiso\Validator\Rule;
|
||||||
use ctiso\Validator\Rule\AbstractRule,
|
use ctiso\Validator\Rule\AbstractRule,
|
||||||
ctiso\Collection;
|
ctiso\Collection;
|
||||||
|
|
||||||
class Match extends AbstractRule
|
class MatchRule extends AbstractRule
|
||||||
{
|
{
|
||||||
public $same;
|
public $same;
|
||||||
|
|
||||||
|
|
@ -28,19 +28,19 @@ class Validator
|
||||||
public function addRuleList(array $input)
|
public function addRuleList(array $input)
|
||||||
{
|
{
|
||||||
$type = array(
|
$type = array(
|
||||||
'date' => 'Validator_Rule_Date',
|
'date' => 'ctiso\\Validator\\Rule\\Date',
|
||||||
'email' => 'Validator_Rule_Email',
|
'email' => 'ctiso\\Validator\\Rule\\Email',
|
||||||
'emaillist'=> 'Validator_Rule_EmailList',
|
'emaillist'=> 'ctiso\\Validator\\Rule\\EmailList',
|
||||||
'match' => 'Validator_Rule_Match',
|
'match' => 'ctiso\\Validator\\Rule\\MatchRule',
|
||||||
'time' => 'Validator_Rule_Time',
|
'time' => 'ctiso\\Validator\\Rule\\Time',
|
||||||
'alpha' => 'Validator_Rule_Alpha',
|
'alpha' => 'ctiso\\Validator\\Rule\\Alpha',
|
||||||
'require' => 'Validator_Rule_Notnull',
|
'require' => 'ctiso\\Validator\\Rule\\Notnull',
|
||||||
'numeric' => 'Validator_Rule_Numeric',
|
'numeric' => 'ctiso\\Validator\\Rule\\Numeric',
|
||||||
'unique' => 'Validator_Rule_Unique',
|
'unique' => 'ctiso\\Validator\\Rule\\Unique',
|
||||||
'filename' => 'Validator_Rule_FileName',
|
'filename' => 'ctiso\\Validator\\Rule\\FileName',
|
||||||
'count' => 'Validator_Rule_Count',
|
'count' => 'ctiso\\Validator\\Rule\\Count',
|
||||||
'isfile' => 'Validator_Rule_IsFile',
|
'isfile' => 'ctiso\\Validator\\Rule\\IsFile',
|
||||||
'code' => 'Validator_Rule_Code'
|
'code' => 'ctiso\\Validator\\Rule\\Code'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Разбор правила проверки
|
// Разбор правила проверки
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@ class View
|
||||||
* Связывет переменную с вложенным шаблоном
|
* Связывет переменную с вложенным шаблоном
|
||||||
*
|
*
|
||||||
* @param string $section переменная шаблона
|
* @param string $section переменная шаблона
|
||||||
* @param CompositeView $view вложенный шаблон
|
* @param View|string $view вложенный шаблон
|
||||||
*/
|
*/
|
||||||
public function setView($section, /*View_View|string*/ $view)
|
public function setView($section, $view/*: View|string*/)
|
||||||
{
|
{
|
||||||
$this->_section [$section] = $view;
|
$this->_section [$section] = $view;
|
||||||
if (is_object($view)) {
|
if (is_object($view)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue