From 67b1c5c5a7f9c8243a924db0756907224d73afad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Sat, 3 May 2025 22:00:08 +0900 Subject: [PATCH] dbms init...1 --- app/Controllers/Admin/MyLogController.php | 14 +++++++++++--- app/Controllers/Admin/UserController.php | 9 ++++++++- app/Controllers/Auth/AuthController.php | 9 +++++++++ app/Controllers/Auth/GoogleController.php | 2 -- app/Controllers/Auth/LocalController.php | 3 --- app/Controllers/CommonController.php | 17 +++++++++-------- 6 files changed, 37 insertions(+), 17 deletions(-) diff --git a/app/Controllers/Admin/MyLogController.php b/app/Controllers/Admin/MyLogController.php index 2a0fb3b..0f8787d 100644 --- a/app/Controllers/Admin/MyLogController.php +++ b/app/Controllers/Admin/MyLogController.php @@ -6,8 +6,9 @@ namespace App\Controllers\Admin; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; -use App\Helpers\MyLogHelper as Helper; + use App\Services\MyLogService as Service; +use App\Helpers\MyLogHelper as Helper; use App\Services\UserService; class MyLogController extends AdminController @@ -16,10 +17,10 @@ class MyLogController extends AdminController public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); - $this->uri_path .= strtolower($this->getService()->getClassName()) . DIRECTORY_SEPARATOR; + $this->uri_path .= strtolower($this->getService()->getClassName()) . '/'; $this->class_path = $this->getService()->getClassPath(); $this->title = lang("{$this->getService()->getClassPath()}.title"); - $this->helper = new Helper(); + $this->helper = $this->getHelper(); } final public function getService(): Service { @@ -28,6 +29,13 @@ class MyLogController extends AdminController } return $this->_service; } + public function getHelper(): mixed + { + if (!$this->_helper) { + $this->_helper = new Helper($this->request); + } + return $this->_helper; + } public function getUserService(): UserService { if (!$this->_userService) { diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index e0c9539..54725c9 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -20,7 +20,7 @@ class UserController extends AdminController $this->uri_path .= strtolower($this->getService()->getClassName()) . '/'; $this->class_path = $this->getService()->getClassPath(); $this->title = lang("{$this->getService()->getClassPath()}.title"); - $this->helper = new Helper(); + $this->helper = $this->getHelper(); } final public function getService(): Service { @@ -29,6 +29,13 @@ class UserController extends AdminController } return $this->_service; } + public function getHelper(): mixed + { + if (!$this->_helper) { + $this->_helper = new Helper($this->request); + } + return $this->_helper; + } //Index,FieldForm관련 public function getFields(): array { diff --git a/app/Controllers/Auth/AuthController.php b/app/Controllers/Auth/AuthController.php index 1f29128..1709b35 100644 --- a/app/Controllers/Auth/AuthController.php +++ b/app/Controllers/Auth/AuthController.php @@ -9,6 +9,7 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; +use App\Helpers\AuthHelper as Helper; use App\Libraries\MySocket\GoogleSocket\API as GoogleSocket; use App\Services\UserService; use App\Entities\UserEntity as Entity; @@ -33,6 +34,13 @@ abstract class AuthController extends CommonController } return $this->_socket; } + public function getHelper(): mixed + { + if (!$this->_helper) { + $this->_helper = new Helper($this->request); + } + return $this->_helper; + } final public function getUserService(): UserService { if (!$this->_userService) { @@ -60,6 +68,7 @@ abstract class AuthController extends CommonController { switch ($action) { case 'login_form': + $this->getHelper()->setViewDatas($this->getViewDatas()); $result = view($this->view_path . $action, ['viewDatas' => $this->getViewDatas()]); break; default: diff --git a/app/Controllers/Auth/GoogleController.php b/app/Controllers/Auth/GoogleController.php index 7f8e1c2..c1c05f7 100644 --- a/app/Controllers/Auth/GoogleController.php +++ b/app/Controllers/Auth/GoogleController.php @@ -6,7 +6,6 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; -use App\Helpers\AuthHelper as Helper; use App\Services\Auth\GoogleService as Service; use App\Entities\UserEntity as Entity; @@ -19,7 +18,6 @@ class GoogleController extends AuthController $this->uri_path .= strtolower($this->getService()->getClassName()) . '/'; $this->class_path = $this->getService()->getClassPath(); $this->title = lang("{$this->getService()->getClassPath()}.title");; - $this->helper = new Helper(); } final public function getService(): Service diff --git a/app/Controllers/Auth/LocalController.php b/app/Controllers/Auth/LocalController.php index 4872196..75d15c9 100644 --- a/app/Controllers/Auth/LocalController.php +++ b/app/Controllers/Auth/LocalController.php @@ -5,9 +5,7 @@ namespace App\Controllers\Auth; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; -use CodeIgniter\HTTP\RedirectResponse; -use App\Helpers\AuthHelper as Helper; use App\Services\Auth\LocalService as Service; use App\Entities\UserEntity as Entity; @@ -20,7 +18,6 @@ class LocalController extends AuthController $this->uri_path .= strtolower($this->getService()->getClassName()) . '/'; $this->class_path = $this->getService()->getClassPath(); $this->title = lang("{$this->getService()->getClassPath()}.title");; - $this->helper = new Helper(); } final public function getService(): Service { diff --git a/app/Controllers/CommonController.php b/app/Controllers/CommonController.php index 4d3e1a6..6e922f0 100644 --- a/app/Controllers/CommonController.php +++ b/app/Controllers/CommonController.php @@ -17,12 +17,12 @@ use Psr\Log\LoggerInterface; use App\Libraries\LogCollector; use App\Services\MyLogService; +use App\Helpers\CommonHelper as Helper; abstract class CommonController extends BaseController { private $_myAuth = null; private $_myLogService = null; - private $_helper = null; private $_viewDatas = []; abstract public function getService(): mixed; abstract public function getFields(): array; @@ -38,10 +38,6 @@ abstract class CommonController extends BaseController $this->myAuthUID = $this->getMyAuth()->getUIDByAuthInfo(); } } - final protected function getMyAuth(): mixed - { - return $this->_myAuth; - } final public function __get($name) { if (!array_key_exists($name, $this->_viewDatas)) { @@ -53,6 +49,10 @@ abstract class CommonController extends BaseController { $this->_viewDatas[$name] = $value; } + final protected function getMyAuth(): mixed + { + return $this->_myAuth; + } final public function getMyLogService(): mixed { if (!$this->_myLogService) { @@ -60,13 +60,14 @@ abstract class CommonController extends BaseController } return $this->_myLogService; } - final public function getHelper(): mixed + public function getHelper(): mixed { if (!$this->_helper) { - $this->_helper = new MyLogService($this->request); + $this->_helper = new Helper($this->request); } return $this->_helper; } + protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string { switch ($action) { @@ -74,7 +75,7 @@ abstract class CommonController extends BaseController case 'modify_form': case 'index': case 'view': - $this->helper->setViewDatas($this->getViewDatas()); + $this->getHelper()->setViewDatas($this->getViewDatas()); $result = view($this->view_path . $action, ['viewDatas' => $this->getViewDatas()]); break; default: