cfmgrv3/app/Controllers/CLI/Cloudflare/API/Account.php
2024-05-15 10:37:47 +09:00

41 lines
1.5 KiB
PHP

<?php
namespace App\Controllers\CLI\Cloudflare\API;
use App\Entities\Cloudflare\API\AccountEntity;
use App\Libraries\Log\Log;
class Account extends API
{
private function getAccounts(int $account_uid): array
{
$this->getAccountModel()->where(['status' => 'active']);
if ($account_uid) {
$this->getAccountModel()->where(['account_uid' => $account_uid]);
} else {
$this->getAccountModel()->where(['status' => 'use']);
}
Log::add("error", __FUNCTION__ . "에서 호출:" . $this->getAccountModel()->getLastQuery());
return $this->getAccountModel()->asObject(AccountEntity::class)->findAll();
}
final public function execute($auth_uid = 0, $page_limit = 0)
{
//transation처리
// $this->getAccountModel()->db->transBegin();
try {
//Zone 처리
foreach ($this->getAccounts((int)$auth_uid) as $entity) {
$api = new \App\Libraries\Cloudflare\API\Zone($entity, true);
$api->reload((int)$page_limit);
}
//transation 완료
// $this->getAccountModel()->db->transCommit();
Log::add("error", __METHOD__ . "에서 Zone Reload 완료");
} catch (\Exception $e) {
// transaction 오류복구
// $this->getAccountModel()->db->transRollback();
Log::add("error", __METHOD__ . "에서 Zone Reload 오류\n" . $e->getMessage());
}
}
}