servermgrv2 init...
This commit is contained in:
parent
7eeb088d71
commit
cefb0b6a3f
@ -68,7 +68,7 @@ class UserController extends AdminController
|
||||
foreach ($this->_viewDatas['fieldRules'] as $field => $rule) {
|
||||
switch ($field) {
|
||||
case 'role':
|
||||
$rules['role.*'] = $rule;
|
||||
$rules[$field . '.*'] = $rule;
|
||||
break;
|
||||
default:
|
||||
$rules[$field] = $rule;
|
||||
|
||||
@ -50,6 +50,7 @@ abstract class BaseController extends Controller
|
||||
*/
|
||||
protected $_model = null;
|
||||
protected $_session = null;
|
||||
protected $_validation = null;
|
||||
protected $_viewPath = '';
|
||||
protected $_viewDatas = array();
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
@ -59,6 +60,7 @@ abstract class BaseController extends Controller
|
||||
// Preload any models, libraries, etc, here.
|
||||
// E.g.: $this->session = \Config\Services::session();
|
||||
$this->_session = \Config\Services::session();
|
||||
$this->_validation = \Config\Services::validation();
|
||||
$this->_viewDatas['layout'] = LAYOUTS['empty'];
|
||||
$this->_viewDatas['session'] = $this->_session;
|
||||
}
|
||||
@ -199,6 +201,11 @@ abstract class BaseController extends Controller
|
||||
protected function update_validate($entity)
|
||||
{
|
||||
//fieldData Rule 검사
|
||||
//추후 VersionUP용
|
||||
// $this->_model->getValidation($this->getFields());
|
||||
// if (! $this->_validation->run($user)) {
|
||||
// throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
||||
// }
|
||||
if (!$this->validate($this->_viewDatas['fieldRules'])) {
|
||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
||||
}
|
||||
|
||||
@ -43,6 +43,7 @@ abstract class BaseModel extends Model
|
||||
private $_user_options = null;
|
||||
private $_className = null;
|
||||
protected $_session = null;
|
||||
protected $_validation = null;
|
||||
protected function __construct(string $className)
|
||||
{
|
||||
$this->_className = $className;
|
||||
@ -53,6 +54,7 @@ abstract class BaseModel extends Model
|
||||
}
|
||||
$this->validationRules = [];
|
||||
$this->_session = \Config\Services::session();
|
||||
$this->_validation = \Config\Services::validation();
|
||||
}
|
||||
final public function getClassName()
|
||||
{
|
||||
@ -114,6 +116,19 @@ abstract class BaseModel extends Model
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
//추후 VersionUP용
|
||||
final public function getValidation(array $fields, string $action = "")
|
||||
{
|
||||
$this->_validation->reset();
|
||||
foreach ($fields as $field) {
|
||||
$this->_validation->setRule(
|
||||
$field,
|
||||
lang($this->getClassName() . '.label.' . $field),
|
||||
$this->getValidationFieldRule($field, $action)
|
||||
);
|
||||
}
|
||||
return $this->_validation;
|
||||
}
|
||||
//Field별 Form Option용
|
||||
public function getOptions(array $conditions = array(), $options = array()): array
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user