daemon-idc init
This commit is contained in:
parent
f4091f475c
commit
8d14be8a75
@ -20,18 +20,18 @@ class GoogleForm extends CommonForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters);
|
||||
$this->setFormOptions($filters);
|
||||
$this->setBatchjobFilters($filters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "access_code":
|
||||
$formRules[$field] = "required|trim|string";
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
|
||||
@ -20,22 +20,22 @@ class LocalForm extends CommonForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters);
|
||||
$this->setFormOptions($filters);
|
||||
$this->setBatchjobFilters($filters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "id":
|
||||
$formRules[$field] = sprintf("required|trim|min_length[4]|max_length[20]%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
$formRules[$field] = sprintf("required|trim|min_length[4]|max_length[20]%s", in_array($this->_action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
break;
|
||||
case "passwd":
|
||||
$formRules[$field] = in_array($action, ["create", "create_form"]) ? "required|trim|string" : "permit_empty|trim|string";
|
||||
$formRules[$field] = in_array($this->_action, ["create", "create_form"]) ? "required|trim|string" : "permit_empty|trim|string";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
|
||||
@ -59,13 +59,13 @@ class BoardForm extends CommonForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "category":
|
||||
@ -82,24 +82,24 @@ class BoardForm extends CommonForm
|
||||
$formRules[$field] = "permit_empty|string";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
}
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
switch ($field) {
|
||||
case 'worker_uid':
|
||||
foreach ($this->getFormOption_process(service('userservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
foreach ($this->getFormOption_process(service('userservice'), $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
default:
|
||||
$options = parent::getFormOption($action, $field, $formDatas, $options);
|
||||
$options = parent::getFormOption($field, $formDatas, $options);
|
||||
break;
|
||||
}
|
||||
return $options;
|
||||
|
||||
@ -32,7 +32,7 @@ abstract class CommonForm
|
||||
private array $_actionButtons = ['view' => ICONS['SEARCH'], 'delete' => ICONS['DELETE']];
|
||||
private array $_batchjobButtons = ['batchjob' => '일괄처리', 'batchjob_delete' => '일괄삭제'];
|
||||
protected $validation = null;
|
||||
|
||||
protected string $_action = '';
|
||||
protected function __construct()
|
||||
{
|
||||
$this->validation = service('validation');
|
||||
@ -40,6 +40,7 @@ abstract class CommonForm
|
||||
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
$this->_action = $action;
|
||||
$actionButtons = ['view' => ICONS['SEARCH'], 'delete' => ICONS['DELETE']];
|
||||
$batchjobButtons = [];
|
||||
$this->setActionButtons($actionButtons);
|
||||
@ -75,10 +76,10 @@ abstract class CommonForm
|
||||
return array_intersect_key($this->_formFields, array_flip($fields));
|
||||
}
|
||||
|
||||
public function setFormRules(string $action, array $fields, $formRules = []): void
|
||||
public function setFormRules(array $fields, $formRules = []): void
|
||||
{
|
||||
foreach ($fields as $field) {
|
||||
$formRules = $this->getFormRule($action, $field, $formRules);
|
||||
$formRules = $this->getFormRule($field, $formRules);
|
||||
}
|
||||
$this->_formRules = $formRules;
|
||||
}
|
||||
@ -91,10 +92,10 @@ abstract class CommonForm
|
||||
return array_intersect_key($this->_formRules, array_flip($fields));
|
||||
}
|
||||
|
||||
final public function setFormOptions(string $action, array $fields, array $formDatas = [], $formOptions = []): void
|
||||
final public function setFormOptions(array $fields, array $formDatas = [], $formOptions = []): void
|
||||
{
|
||||
foreach ($fields as $field) {
|
||||
$formOptions[$field] = $formOptions[$field] ?? $this->getFormOption($action, $field, $formDatas);
|
||||
$formOptions[$field] = $formOptions[$field] ?? $this->getFormOption($this->_action, $field, $formDatas);
|
||||
}
|
||||
$this->_formOptions = $formOptions;
|
||||
}
|
||||
@ -168,7 +169,7 @@ abstract class CommonForm
|
||||
* - 실패 시 FormValidationException(errors 배열)을 throw
|
||||
* (AJAX에서 422로 내려보내기 위함)
|
||||
*/
|
||||
final public function validate(string $action, array &$formDatas): void
|
||||
final public function validate(array &$formDatas): void
|
||||
{
|
||||
try {
|
||||
// 1) 전체 룰/필드
|
||||
@ -184,7 +185,7 @@ abstract class CommonForm
|
||||
// - modify 계열: 전달받은 formDatas 키에 해당하는 룰만
|
||||
$targetFields = [];
|
||||
|
||||
if (in_array($action, ['modify', 'modify_form'], true)) {
|
||||
if (in_array($this->_action, ['modify', 'modify_form'], true)) {
|
||||
// 전달받은 필드만 검증
|
||||
$targetFields = array_keys($formDatas);
|
||||
|
||||
@ -276,14 +277,14 @@ abstract class CommonForm
|
||||
return $label;
|
||||
}
|
||||
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case $this->getAttribute('pk_field'):
|
||||
if (!$this->getAttribute('useAutoIncrement')) {
|
||||
$formRules[$field] = sprintf(
|
||||
"required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]%s",
|
||||
in_array($action, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
||||
in_array($this->_action, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
||||
);
|
||||
} else {
|
||||
$formRules[$field] = "required|numeric";
|
||||
@ -293,14 +294,14 @@ abstract class CommonForm
|
||||
case $this->getAttribute('title_field'):
|
||||
$formRules[$field] = sprintf(
|
||||
"required|trim|string%s",
|
||||
in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
||||
in_array($this->_action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
||||
);
|
||||
break;
|
||||
|
||||
case "code":
|
||||
$formRules[$field] = sprintf(
|
||||
"required|regex_match[/^[a-zA-Z0-9가-힣\-\_]+$/]|min_length[4]%s",
|
||||
in_array($action, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
||||
in_array($this->_action, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
||||
);
|
||||
break;
|
||||
|
||||
@ -334,13 +335,13 @@ abstract class CommonForm
|
||||
* Options
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
protected function getFormOption_process($service, string $action, string $field, array $formDatas = []): array
|
||||
protected function getFormOption_process($service, string $field, array $formDatas = []): array
|
||||
{
|
||||
$entities = [];
|
||||
|
||||
switch ($field) {
|
||||
default:
|
||||
if (in_array($action, ['create_form', 'modify_form', 'alternative_create_form'])) {
|
||||
if (in_array($this->_action, ['create_form', 'modify_form', 'alternative_create_form'])) {
|
||||
if (array_key_exists($field, $formDatas)) {
|
||||
$where = sprintf("status = '%s' OR %s='%s'", STATUS['AVAILABLE'], $this->getAttribute('pk_field'), $formDatas[$field]);
|
||||
} else {
|
||||
@ -356,20 +357,20 @@ abstract class CommonForm
|
||||
return $entities;
|
||||
}
|
||||
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
|
||||
switch ($field) {
|
||||
case 'user_uid':
|
||||
foreach ($this->getFormOption_process(service('userservice'), $action, $field, $formDatas) as $entity) {
|
||||
foreach ($this->getFormOption_process(service('userservice'), $field, $formDatas) as $entity) {
|
||||
$tempOptions[$entity->getPK()] = $entity->getTitle();
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
|
||||
case 'clientinfo_uid':
|
||||
foreach ($this->getFormOption_process(service('customer_clientservice'), $action, $field, $formDatas) as $entity) {
|
||||
foreach ($this->getFormOption_process(service('customer_clientservice'), $field, $formDatas) as $entity) {
|
||||
$tempOptions[$entity->getPK()] = $entity->getCustomTitle();
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
|
||||
@ -53,14 +53,14 @@ class InquiryForm extends CommonForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
}
|
||||
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "title":
|
||||
@ -68,13 +68,13 @@ class InquiryForm extends CommonForm
|
||||
$formRules[$field] = "required|trim|string";
|
||||
break;
|
||||
case "email":
|
||||
$formRules[$field] = sprintf("required|trim|valid_email%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
$formRules[$field] = sprintf("required|trim|valid_email%s", in_array($this->_action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
break;
|
||||
case "status":
|
||||
$formRules[$field] = "permit_empty|trim|string";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
|
||||
@ -35,26 +35,26 @@ class UserForm extends CommonForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "id":
|
||||
$formRules[$field] = sprintf("required|trim|min_length[4]|max_length[20]%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
$formRules[$field] = sprintf("required|trim|min_length[4]|max_length[20]%s", in_array($this->_action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
break;
|
||||
case "passwd":
|
||||
$formRules[$field] = sprintf("%s|%s", in_array($action, ["create", "create_form"]) ? "required" : "permit_empty", "trim|string");
|
||||
$formRules[$field] = sprintf("%s|%s", in_array($this->_action, ["create", "create_form"]) ? "required" : "permit_empty", "trim|string");
|
||||
break;
|
||||
case "confirmpassword":
|
||||
$formRules[$field] = sprintf("%s|%s", in_array($action, ["create", "create_form"]) ? "required" : "permit_empty", "trim|string|matches[passwd]");
|
||||
$formRules[$field] = sprintf("%s|%s", in_array($this->_action, ["create", "create_form"]) ? "required" : "permit_empty", "trim|string|matches[passwd]");
|
||||
break;
|
||||
case "email":
|
||||
$formRules[$field] = sprintf("required|trim|valid_email%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
$formRules[$field] = sprintf("required|trim|valid_email%s", in_array($this->_action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
break;
|
||||
case "role":
|
||||
// $formRules[$field] = 'required|trim|string';
|
||||
@ -62,7 +62,7 @@ class UserForm extends CommonForm
|
||||
$formRules['role.*'] = 'permit_empty|trim|in_list[manager,cloudflare,firewall,security,director,master]';
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user