_className .= '/UserSNS'; $this->_model = new UserSNSModel(); $this->_defines = [ 'insert' => [ 'fields' => ['site', 'user_uid', 'name', 'email', 'status'], 'fieldFilters' => ['status'], 'fieldRules' => [ 'name' => 'required|min_length[2]|max_length[20]', 'email' => 'required|valid_email', 'status' => 'required|in_list[use,unuse]', ] ], 'index' => [ 'fields' => ['site', 'user_uid', 'name', 'email', 'status', 'created_at'], 'fieldFilters' => ['user_uid', 'status'], 'batchjobFilters' => [], ], 'excel' => [ 'fields' => ['site', 'user_uid', 'name', 'email', 'status', 'created_at'], 'fieldFilters' => ['user_uid', 'status'], ], ]; helper($this->_className); $this->_viewPath = strtolower($this->_className); $this->_viewDatas['title'] = lang($this->_className . '.title'); $this->_viewDatas['className'] = $this->_className; } private function getUserModel(): UserModel { return is_null($this->_userModel) ? new UserModel() : $this->_userModel; } //Field별 Form Option용 protected function getFieldFormOption(string $field): array { switch ($field) { case 'user_uid': if (is_null($this->_user_uids)) { //모든 필요한 FormOption등 조기화작업 필요 $this->_user_uids = [DEFAULTS['EMPTY'] => lang($this->_className . '.label.' . $field) . ' 선택']; foreach ($this->getUserModel()->findAll() as $user) { $this->_user_uids[$user['uid']] = $user['name']; } } return $this->_user_uids; break; default: return parent::getFieldFormOption($field); break; } } //Insert관련 protected function insert_process() { //암호값 hash작업 $this->_viewDatas['fieldDatas']['passwd'] = password_hash($this->_viewDatas['fieldDatas']['passwd'], PASSWORD_DEFAULT); return parent::insert_process(); } //Update관련 protected function update_process($entity) { //암호값 hash작업 $entity->passwd = password_hash($entity->passwd, PASSWORD_DEFAULT); return parent::update_process($entity); } ////Action 모음 //Insert관련 final public function insert() { return $this->insert_procedure(); } //Update관련 final public function update($uid) { return $this->update_procedure($uid); } //Toggle관련 final public function toggle($uid, string $field) { return $this->toggle_procedure($uid, $field); } //Batchjob 관련 final public function batchjob() { return $this->batchjob_procedure(); } //Delete 관련 final public function delete($uid) { return $this->delete_procedure($uid); } //View 관련 final public function view($uid) { return $this->view_procedure($uid); } //Index 관련 final public function index() { return $this->index_procedure(); } //Excel 관련 final public function excel() { return $this->excel_procedure(); } }