getAuthContext(); } final public function addActionPaths(string $path) { $this->_action_paths[] = $path; } final public function getActionPaths($isArray = true, $delimeter = DIRECTORY_SEPARATOR): array|string { return $isArray ? $this->_action_paths : implode($delimeter, $this->_action_paths); } final public function addViewDatas(string $key, mixed $value) { $this->_viewDatas[$key] = $value; } final public function getViewDatas(?string $key = null): mixed { if ($key === null) { return $this->_viewDatas; } return $this->_viewDatas[$key] ?? null; } //공통 필수기능 protected function doValidation(string $action): array { $dynamicRules = []; foreach ($this->service->getFormRules($action) as $field => $rule) { list($field, $rule) = $this->getFormRule($action, $field, $rule); $dynamicRules[$field] = $rule; } //변경할 값 확인 : Upload된 파일 검증시 $this->request->getPOST()보다 먼처 체크필요 if (!$this->validate($dynamicRules)) { throw new \Exception(static::class . "에서 작업 데이터 검증 오류발생\n" . implode( "\n", $this->validator->getErrors() )); } return $this->validator->getValidated(); } protected function getFormRule(string $action, string $field, string $rule): array { switch ($field) { default: break; } return array($field, $rule); } protected function action_init_process(string $action): void { $this->addViewDatas('action', $action); $this->addViewDatas('authContext', $this->getAuthContext()); $this->addViewDatas('classPath', $this->service->getClassPaths(false)); } protected function action_rediect_process(string $message): RedirectResponse { $redirect_url = $this->getAuthContext()->popPreviousUrl() ?? implode(DIRECTORY_SEPARATOR, $this->getActionPaths()); return redirect()->to($redirect_url)->with('message', $message); } protected function action_render_process(array $view_paths, string $view_file, array $viewDatas): string { $lastest_path = array_pop($view_paths); //paths는 마지막을 뺀 앞단까지만 남음 // ✅ 중간 안내 화면으로 // return view('posts/success_redirect', [ // 'message' => '게시글이 성공적으로 등록되었습니다.', // 'redirectUrl' => route_to('posts_list') // ]); // 중요한 작업 (결제 완료, 오류 등) → “로딩 페이지(View)”로 안내 후 JS redirect $full_path = implode(DIRECTORY_SEPARATOR, [ ...$view_paths, $this->request->getVar('ActionTemplate') ?? $lastest_path, $view_file ]); $view_datas = [ ...$viewDatas, 'forms' => ['attributes' => ['method' => "post",], 'hiddens' => []], ]; helper(['form', __FUNCTION__]); return view($full_path, ['viewDatas' => $view_datas]); } }