_auth_entity = $auth_entity; self::$_request_max = getenv("cfmgr.request.max"); } abstract protected function getArrayByResult($result, array $formDatas = []): array; final protected function getAuthModel(): AuthModel { if ($this->_authModel === null) { $this->_authModel = new AuthModel(); } return $this->_authModel; } final protected function getAccountModel(): AccountModel { if ($this->_accountModel === null) { $this->_accountModel = new AccountModel(); } return $this->_accountModel; } final protected function getClient(): Client { if ($this->_client === null) { // Guzzle HTTP 클라이언트를 설정하면서 Cloudflare API 토큰 사용 $this->_client = new Client([ 'base_uri' => 'https://api.cloudflare.com/client/v4/', 'headers' => [ 'X-Auth-Email' => $this->_auth_entity->getID(), // 인증 토큰 사용 'X-Auth-Key' => $this->_auth_entity->getAuthKey(), // 인증 토큰 사용 'Content-Type' => 'application/json', ] ]); } if (self::$_request >= self::$_request_max) { log_message('warning', sprintf("--Cloudflare API Call %s초 대기 시작--", self::$_request_timewait)); sleep(intval(getenv("cf.mgr.request.time.wait"))); self::$_request = 0; log_message('warning', sprintf("--Cloudflare API Call %s초 대기 종료--", self::$_request_timewait)); } self::$_request++; return $this->_client; } final protected function reload_procedure($uri): array { $page = 1; //Page는 1부터 시작해야함 $perpage_max = getenv("cfmgr.request.perpage.max"); $results = []; do { $query = [ 'page' => $page, 'per_page' => $perpage_max, 'match' => 'all', ]; $cf = $this->getClient()->get($uri, $query); $cf = json_decode($cf->getBody()); if (!$cf->success) { throw new \Exception(__FUNCTION__ . "에서 실패:\n" . var_export($cf, true)); } $results[] = $cf->result; //Loop 제한 : 한페이지에서 가져온 갯수가 perpage_max보다 적다는것은 더이상 다음페이지기 없으므로 0로 종료시키기 위함 $page = count($cf->result) < $perpage_max ? 0 : $page + 1; } while (0 < $page); return $results; } }