service === null) { $this->service = service('mylogservice'); } $this->addActionPaths($this::PATH); } protected function action_init_process(string $action): void { $fields = ['title', 'content']; $filters = []; parent::action_init_process($action); switch ($action) { case 'create': case 'create_form': case 'modify': case 'modify_form': break; case 'view': $fields = [...$fields, 'created_at']; break; case 'index': $fields = [...$fields, '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); } //Action작업관련 protected function create_form_process(): void { //Form Default값 설정 $formDatas = []; $this->addViewDatas('formDatas', $formDatas); } protected function create_process(): array { //요청 데이터를 DTO 객체로 변환 $dto = new MylogDTO($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 MylogEntity) { throw new \Exception("{$uid}에 해당하는 로그를 찾을수 없습니다."); } $this->addViewDatas('entity', $entity); } protected function modify_process($uid): array { //요청 데이터를 DTO 객체로 변환 $dto = new MylogDTO($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): MylogEntity { if (!$uid) { throw new \Exception("로그정보 번호가 정의 되지 않았습니다."); } $entity = $this->service->getEntity($uid); if (!$entity instanceof MylogEntity) { throw new \Exception("{$uid}에 해당하는 로그정보를 찾을수 없습니다."); } return $entity; } }