From e196610e65d9d666191e053f4f3b9f48ad7c77b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Thu, 31 Oct 2024 11:47:08 +0900 Subject: [PATCH] cfmgrv4 init...4 --- app/Controllers/Admin/UserController.php | 6 +++--- app/Controllers/MVController.php | 14 ++++++++------ app/Helpers/Cloudflare/RecordHelper.php | 13 ------------- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index ab889a3..3893c6b 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -35,15 +35,15 @@ class UserController extends AdminController } return $this->service; } - protected function setValidationRule($field, Validation $validation, string $action): Validation + protected function setValidation(string $action, string $field, Validation $validation): Validation { switch ($field) { case 'role': //아래 Rule Array는 필드명.* checkbox를 사용 - $validation->setRule($field . ".*", $field, $this->getModel()->getFieldRule($action, $field)); + $validation->setRule("{$field}.*", $field, $this->getModel()->getFieldRule($action, $field)); break; default: - $validation = parent::setValidationRule($field, $validation, $action); + $validation = parent::setValidation($field, $action, $validation); break; } return $validation; diff --git a/app/Controllers/MVController.php b/app/Controllers/MVController.php index 2cbc624..85b05ec 100644 --- a/app/Controllers/MVController.php +++ b/app/Controllers/MVController.php @@ -22,7 +22,7 @@ abstract class MVController extends CommonController abstract protected function getModel(): mixed; abstract protected function getService(): mixed; //Field별 Form Rule용 - protected function setValidationRule($field, Validation $validation, string $action): Validation + protected function setValidation(string $action, string $field, Validation $validation): Validation { switch ($field) { default: @@ -31,10 +31,11 @@ abstract class MVController extends CommonController } return $validation; } - final protected function getValidation(array $fields, Validation $validation, string $action): Validation + final protected function getValidation(string $action, array $fields): Validation { + $validation = service('validation'); foreach ($fields as $field) { - $validation = $this->setValidationRule($field, $validation, $action); + $validation = $this->setValidation($action, $field, $validation); } return $validation; } @@ -80,7 +81,7 @@ abstract class MVController extends CommonController protected function create_validate(string $action, array $fields): array { //변경할 값 확인 : Upload된 파일 검증시 $this->request->getPOST()보다 먼처 체크필요 - $validation = $this->getValidation($fields, service('validation'), $action); + $validation = $this->getValidation($action, $fields); if (!$validation->withRequest($this->request)->run()) { throw new \Exception("{$this->getService()->class_name} 작업 데이터 검증 오류발생\n" . implode( "\n", @@ -143,7 +144,7 @@ abstract class MVController extends CommonController final protected function modify_validate(string $action, array $fields): array { //변경할 값 확인 : Upload된 파일 검증시 $this->request->getVar()보다 먼처 체크필요 - $validation = $this->getValidation($fields, service('validation'), $action); + $validation = $this->getValidation($action, $fields); if (!$validation->withRequest($this->request)->run()) { throw new \Exception("{$this->getService()->class_name} 작업 데이터 검증 오류발생\n" . implode( "\n", @@ -152,6 +153,7 @@ abstract class MVController extends CommonController } return $validation->getValidated(); } + //modify,toggle,batchjob 공통사용 protected function modify_process(mixed $uid): void { $this->formDatas = $this->modify_validate($this->action, $this->fields); @@ -268,7 +270,7 @@ abstract class MVController extends CommonController return redirect()->back()->with('error', $e->getMessage()); } } - //삭제 + //삭제 delete,batchjob_delete 공통사용 protected function delete_process(mixed $uid): void { //자신정보정의 diff --git a/app/Helpers/Cloudflare/RecordHelper.php b/app/Helpers/Cloudflare/RecordHelper.php index b17c35c..760a65e 100644 --- a/app/Helpers/Cloudflare/RecordHelper.php +++ b/app/Helpers/Cloudflare/RecordHelper.php @@ -12,19 +12,6 @@ class RecordHelper extends MVCHelper { parent::__construct(); } - public function getFieldLabel(string $field, array $viewDatas, array $extras = []): string - { - switch ($field) { - case 'hosts': - $extras = ["class" => 'text-danger', ...$extras]; - $label = form_label(lang("{$viewDatas['class_path']}.label.{$field}"), $field, $extras); - break; - default: - $label = parent::getFieldLabel($field, $viewDatas, $extras); - break; - } - return $label; - } public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string { if (in_array($viewDatas['action'], ['create', 'modify'])) {