_db = \Config\Database::connect(); } private function auth_process(mixed $uid = false): array { $authModel = model(AuthModel::class); if (is_numeric($uid) && $uid > 0) { $authModel->where(AuthModel::PK, intval($uid)); } else { $authModel->where('status', DEFAULTS["STATUS"]); } $entitys = $authModel->getEntitys(); log_message("debug", $authModel->getLastQuery()); return $entitys; } private function account_process(AuthEntity $auth_entity): array { $account = new AccountService(); return $account->reload($auth_entity); } private function zone_process(AccountEntity $account_entity): array { $zone = new ZoneService(); return $zone->reload($account_entity); } private function record_process(ZoneEntity $zone_entity): array { $record = new RecordService(); return $record->reload($zone_entity); } private function firewall_process(ZoneEntity $zone_entity): array { $firewall = new FirewallService(); return $firewall->reload($zone_entity); } public function reload(mixed $uid = false): void { //Transaction Start // $this->_db->transStart(); try { $auths = $this->auth_process($uid); foreach ($auths as $auth) { $accounts = $this->account_process($auth); foreach (array_values($accounts) as $account) { $zones = $this->zone_process($account); $cnt = 1; $total = count($zones); foreach (array_values($zones) as $zone) { log_message("notice", "\n-----------[{$cnt}/$total}] Zone {$zone->getTitle()}의 Record/Firewall 처리 시작-----------"); $records = $this->record_process($zone); $firewalls = $this->firewall_process($zone); log_message("notice", "\n-----------[{$cnt}/$total}] Zone {$zone->getTitle()}의 Record/Firewall 처리 완료-----------"); $cnt++; } } } log_message("notice", "Reload 작업을 완료하였습니다."); // $this->_db->transCommit(); } catch (\Exception $e) { //Transaction Rollback // $this->_db->transRollback(); log_message( "error", "Reload 작업을 실패하였습니다.\n--------------\n" . $e->getMessage() . "\n--------------\n" ); } } }