service === null) { $this->service = service('userservice'); } $this->addActionPaths($this::PATH); } //Action작업관련 protected function action_init_process(string $action): void { $fields = ['id', 'passwd', 'confirmpassword', 'name', 'email', 'mobile', 'role']; $filters = ['role', 'status']; switch ($action) { case 'create': case 'create_form': case 'modify': case 'modify_form': break; case 'view': $fields = ['id', 'name', 'email', 'mobile', 'role', 'status', 'created_at']; break; case 'index': $fields = ['id', 'name', 'email', 'mobile', 'role', 'status', 'created_at']; break; default: throw new \Exception("[{$action}] 지원하지 않는 action입니다."); // break; } $this->service->getFormService()->setFormFields($fields); $this->service->getFormService()->setFormRules($action, $fields); $this->service->getFormService()->setFormFilters($filters); $this->service->getFormService()->setFormOptions($filters); $this->service->getFormService()->setBatchjobFilters($filters); parent::action_init_process($action); } protected function create_form_process(): void { //Form Default값 설정 $formDatas = ['role' => [ROLE['USER']['MANAGER']]]; $this->addViewDatas('formDatas', $formDatas); } protected function create_process(): array { //요청 데이터를 DTO 객체로 변환 $dto = new UserDTO($this->request->getPost()); $entity = $this->service->create($dto); return array($entity, "{$entity->getTitle()} 계정 생성이 완료되었습니다."); } protected function modify_form_process($uid): void { if (!$uid) { throw new \Exception("계정 번호가 정의 되지 않았습니다."); } $entity = $this->service->getEntity($uid); if (!$entity instanceof UserEntity) { throw new \Exception("{$uid}에 해당하는 계정을 찾을수 없습니다."); } $this->addViewDatas('entity', $entity); } protected function modify_process($uid): array { //요청 데이터를 DTO 객체로 변환 $dto = new UserDTO($this->request->getPost()); $entity = $this->service->modify($uid, $dto); return array($entity, "{$entity->getTitle()} 계정 수정이 완료되었습니다."); } protected function delete_process($uid): array { $entity = $this->service->delete($uid); return array($entity, "{$entity->getTitle()} 계정 삭제 완료되었습니다."); } protected function view_process($uid): UserEntity { if (!$uid) { throw new \Exception("계정 번호가 정의 되지 않았습니다."); } $entity = $this->service->getEntity($uid); if (!$entity instanceof UserEntity) { throw new \Exception("{$uid}에 해당하는 계정을 찾을수 없습니다."); } return $entity; } }