service === null) { $this->service = service('localauth'); } $this->_paths[] = self::PATH; } protected function getFormRule(string $action, string $field, string $rule): array { switch ($field) { case 'role': $field = "{$field}.*"; break; } return parent::getFormRule($action, $field, $rule); } //Index,FieldForm관련. final public function profile_form(mixed $uid): RedirectResponse|string { try { $this->getService()->setAction(__FUNCTION__); $this->getService()->setFormFields(); $this->getService()->setFormFilters(); $this->getService()->setFormRules(); $this->getService()->setFormOptions(); //기본값정의 $this->getService()->setFormDatas($this->request->getGet()); //기존 Entity 가져오기 $entity = $this->getService()->getEntity($uid); if (!$entity instanceof UserEntity) { throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다."); } $this->entity = $entity; helper(['form']); $this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []]; return $this->getResultSuccess(); } catch (\Exception $e) { return $this->getResultFail($e->getMessage()); } } final public function profile(int $uid): RedirectResponse|string { //Transaction Start $db = \Config\Database::connect(); $this->_db->transStart(); try { $this->getService()->setAction(__FUNCTION__); $this->getService()->setFormFields(); $this->getService()->setFormFilters(); $this->getService()->setFormRules(); //전달값정의 $this->getService()->setFormDatas($this->request->getPost()); $this->doValidations(); //기존 Entity 가져오기 $entity = $this->getService()->getEntity($uid); if (!$entity instanceof UserEntity) { throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다."); } $this->entity = $this->modify_process($entity, $this->getService()->getFormDatas()); $this->_db->transCommit(); return $this->getResultSuccess(); } catch (\Exception $e) { $this->_db->transRollback(); return $this->getResultFail($e->getMessage()); } } }