diff --git a/app/Services/Auth/AuthService.php b/app/Services/Auth/AuthService.php index 8c890b7..f5970d7 100644 --- a/app/Services/Auth/AuthService.php +++ b/app/Services/Auth/AuthService.php @@ -8,16 +8,15 @@ use App\Services\CommonService; use CodeIgniter\Session\Session; // 참고:https://github.com/SyntaxPhoenix/iloclient -class AuthService extends CommonService +abstract class AuthService extends CommonService { private ?Session $_session = null; private ?UserModel $_model = null; - public function __construct(string $class_name, string $class_path) + public function __construct() { - parent::__construct($class_name, $class_path); + parent::__construct(); } - final public function getSession(): Session { if ($this->_session === null) { diff --git a/app/Services/Auth/GoogleService.php b/app/Services/Auth/GoogleService.php index 5f41c0b..675dfe3 100644 --- a/app/Services/Auth/GoogleService.php +++ b/app/Services/Auth/GoogleService.php @@ -14,9 +14,16 @@ class GoogleService extends AuthService public function __construct(mixed $mySocket) { $this->_mySocket = $mySocket; - parent::__construct("Google", class_path: "Google"); + parent::__construct(); + } + final public function getClassName(): string + { + return "Google"; + } + final public function getClassPath(): string + { + return $this->getClassName(); } - public function getMySocket(string $access_code): mixed { if ($this->_mySocket === null) { diff --git a/app/Services/Auth/LocalService.php b/app/Services/Auth/LocalService.php index 0f6cacd..c240a37 100644 --- a/app/Services/Auth/LocalService.php +++ b/app/Services/Auth/LocalService.php @@ -8,9 +8,16 @@ class LocalService extends AuthService { public function __construct() { - parent::__construct("Local", class_path: "Local"); + parent::__construct(); + } + final public function getClassName(): string + { + return "Local"; + } + final public function getClassPath(): string + { + return $this->getClassName(); } - public function checkUser(array $formDatas): UserEntity { if (!isset($formDatas['id']) || !$formDatas['id']) { diff --git a/app/Services/Cloudflare/AccountService.php b/app/Services/Cloudflare/AccountService.php index 8484f22..d2a32b0 100644 --- a/app/Services/Cloudflare/AccountService.php +++ b/app/Services/Cloudflare/AccountService.php @@ -16,9 +16,16 @@ class AccountService extends CloudflareService public function __construct() { - parent::__construct("Account", "Account"); + parent::__construct(); + } + final public function getClassName(): string + { + return "Account"; + } + final public function getClassPath(): string + { + return parent::getClassPath() . $this->getClassName(); } - private function getParentEntity(): AuthEntity { if ($this->_parent_entity === null) { diff --git a/app/Services/Cloudflare/AuditLogService.php b/app/Services/Cloudflare/AuditLogService.php index 1683cc8..ebcf2ba 100644 --- a/app/Services/Cloudflare/AuditLogService.php +++ b/app/Services/Cloudflare/AuditLogService.php @@ -12,12 +12,18 @@ class AuditLogService extends CloudflareService private ?AuditLogModel $_model = null; private ?AccountModel $_accountModel = null; private ?ZoneModel $_zoneModel = null; - public function __construct() { - parent::__construct("AuditLog", "AuditLog"); + parent::__construct(); + } + final public function getClassName(): string + { + return "AuditLog"; + } + final public function getClassPath(): string + { + return parent::getClassPath() . $this->getClassName(); } - public function getModel(): AuditLogModel { if ($this->_model === null) { diff --git a/app/Services/Cloudflare/AuthService.php b/app/Services/Cloudflare/AuthService.php index 5b8a647..a8ee971 100644 --- a/app/Services/Cloudflare/AuthService.php +++ b/app/Services/Cloudflare/AuthService.php @@ -12,9 +12,16 @@ class AuthService extends CloudflareService public function __construct() { - parent::__construct("Auth", "Auth"); + parent::__construct(); + } + final public function getClassName(): string + { + return "Auth"; + } + final public function getClassPath(): string + { + return parent::getClassPath() . $this->getClassName(); } - public function getModel(): AuthModel { if ($this->_model === null) { diff --git a/app/Services/Cloudflare/CloudflareService.php b/app/Services/Cloudflare/CloudflareService.php index 4d8ddc9..ce1fd23 100644 --- a/app/Services/Cloudflare/CloudflareService.php +++ b/app/Services/Cloudflare/CloudflareService.php @@ -13,11 +13,14 @@ abstract class CloudflareService extends CommonService private array $_mySockets = []; private ?AuthEntity $_auth_entity = null; private ?AuthModel $_authModel = null; - protected function __construct(string $class_name, string $class_path) + public function __construct() { - parent::__construct($class_name, "Cloudflare/" . $class_path); + parent::__construct(); + } + public function getClassPath(): string + { + return "Cloudflare/"; } - final public function getMySocket(): CloudflareSocket { $authEntityPK = $this->getAuthEntity()->getPK(); diff --git a/app/Services/Cloudflare/FirewallService.php b/app/Services/Cloudflare/FirewallService.php index 4d71a26..026005a 100644 --- a/app/Services/Cloudflare/FirewallService.php +++ b/app/Services/Cloudflare/FirewallService.php @@ -16,7 +16,15 @@ class FirewallService extends CloudflareService public function __construct() { - parent::__construct("Firewall", "Firewall"); + parent::__construct(); + } + final public function getClassName(): string + { + return "Firewall"; + } + final public function getClassPath(): string + { + return parent::getClassPath() . $this->getClassName(); } private function getParentEntity(): ZoneEntity diff --git a/app/Services/Cloudflare/RecordService.php b/app/Services/Cloudflare/RecordService.php index c72d675..ac31031 100644 --- a/app/Services/Cloudflare/RecordService.php +++ b/app/Services/Cloudflare/RecordService.php @@ -17,9 +17,16 @@ class RecordService extends CloudflareService public function __construct() { - parent::__construct("Record", "Record"); + parent::__construct(); + } + final public function getClassName(): string + { + return "Record"; + } + final public function getClassPath(): string + { + return parent::getClassPath() . $this->getClassName(); } - private function getParentEntity(): ZoneEntity { if ($this->_parent_entity === null) { diff --git a/app/Services/Cloudflare/ZoneService.php b/app/Services/Cloudflare/ZoneService.php index baf0b3e..5ca1782 100644 --- a/app/Services/Cloudflare/ZoneService.php +++ b/app/Services/Cloudflare/ZoneService.php @@ -23,9 +23,16 @@ class ZoneService extends CloudflareService public function __construct() { - parent::__construct("Zone", class_path: "Zone"); + parent::__construct(); + } + final public function getClassName(): string + { + return "Zone"; + } + final public function getClassPath(): string + { + return parent::getClassPath() . $this->getClassName(); } - private function getParentEntity(): AccountEntity { if ($this->_parent_entity === null) { diff --git a/app/Services/CommonService.php b/app/Services/CommonService.php index 82445b1..e2daa6f 100644 --- a/app/Services/CommonService.php +++ b/app/Services/CommonService.php @@ -5,16 +5,11 @@ namespace App\Services; abstract class CommonService { private $_serviceDatas = []; - private $class_name = ""; - private $class_path = ""; - public function __construct(string $class_name, string $class_path) - { - $this->class_name = $class_name; - $this->class_path = $class_path; - // dd($this->class_name, $this->class_path); - } + public function __construct() {} abstract public function getModel(): mixed; + abstract public function getClassName(): string; + abstract public function getClassPath(): string; final public function __get($name) { if (!array_key_exists($name, $this->_serviceDatas)) { @@ -26,14 +21,6 @@ abstract class CommonService { $this->_serviceDatas[$name] = $value; } - final public function getClassName(): string - { - return $this->class_name; - } - final public function getClassPath(): string - { - return $this->class_path; - } final public function getServiceDatas(): array { return $this->_serviceDatas; diff --git a/app/Services/MapurlService.php b/app/Services/MapurlService.php index 319698b..ec83c9e 100644 --- a/app/Services/MapurlService.php +++ b/app/Services/MapurlService.php @@ -12,7 +12,15 @@ class MapurlService extends CommonService private ?MapurlModel $_model = null; public function __construct() { - parent::__construct("Mapurl", "Mapurl"); + parent::__construct(); + } + final public function getClassName(): string + { + return "Mapurl"; + } + final public function getClassPath(): string + { + return parent::getClassPath() . $this->getClassName(); } public function getModel(): MapurlModel { diff --git a/app/Services/MyLogService.php b/app/Services/MyLogService.php index 9ff8e9d..e0b924b 100644 --- a/app/Services/MyLogService.php +++ b/app/Services/MyLogService.php @@ -10,16 +10,14 @@ class MyLogService { private static ?MyLogModel $_model = null; private static $_logBuffers = []; - private static $_class_name = "MyLog"; - private static $_class_path = "MyLog"; public function __construct() {} final public function getClassName(): string { - return self::$_class_name; + return "MyLog"; } final public function getClassPath(): string { - return self::$_class_path; + return $this->getClassName(); } static public function getModel(): MyLogModel { diff --git a/app/Services/UserSNSService.php b/app/Services/UserSNSService.php index 1cb00b8..b2f250b 100644 --- a/app/Services/UserSNSService.php +++ b/app/Services/UserSNSService.php @@ -11,7 +11,15 @@ class UserSNSService extends CommonService private ?UserSNSModel $_model = null; public function __construct() { - parent::__construct("UserSNS", "UserSNS"); + parent::__construct(); + } + final public function getClassName(): string + { + return "UserSNS"; + } + final public function getClassPath(): string + { + return parent::getClassPath() . $this->getClassName(); } public function getModel(): UserSNSModel { diff --git a/app/Services/UserService.php b/app/Services/UserService.php index fc28b51..0864084 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -10,7 +10,15 @@ class UserService extends CommonService private ?UserModel $_model = null; public function __construct() { - parent::__construct("User", "User"); + parent::__construct(); + } + final public function getClassName(): string + { + return "User"; + } + final public function getClassPath(): string + { + return $this->getClassName(); } public function getModel(): UserModel {