cfmgrv4 init...4

This commit is contained in:
최준흠 2024-10-30 12:39:20 +09:00
parent 347c4a7e07
commit 22a8267815

View File

@ -4,13 +4,15 @@ namespace App\Services\Cloudflare;
use App\Entities\Cloudflare\AccountEntity;
use App\Entities\Cloudflare\AuditLogEntity;
use App\Models\Cloudflare\ZoneModel;
use App\Models\Cloudflare\AccountModel;
use App\Models\Cloudflare\AuditLogModel;
use App\Models\Cloudflare\ZoneModel;
use stdClass;
class AuditLogService extends CloudflareService
{
private ?AuditLogModel $_model = null;
private ?AccountModel $_accountModel = null;
private ?ZoneModel $_zoneModel = null;
public function __construct()
{
@ -32,6 +34,13 @@ class AuditLogService extends CloudflareService
}
return $this->_zoneModel;
}
protected function getAccountModel(): AccountModel
{
if ($this->_accountModel === null) {
$this->_accountModel = new AccountModel();
}
return $this->_accountModel;
}
protected function getArrayByResult(\stdClass $result, array $formDatas = []): array
{
@ -55,13 +64,18 @@ class AuditLogService extends CloudflareService
$this->getZoneModel()->where('domain', $entity->getZoneName());
$zone_entity = $this->getZoneModel()->getEntity();
if ($zone_entity !== null) {
// $zone_entity = $zone_service->sync($entity, $zone_entity);
// //해당 Zone의 Record reload작업한다
// $record_service = new RecordService();
// $record_service->reload($zone_entity);
// //해당 Zone의 Firewall reload작업한다
// $firewall_service = new FirewallService();
// $firewall_service->reload($zone_entity);
$account_entity = $this->getAccountModel()->getEntityBYPK($zone_entity->getParent());
if ($account_entity === null) {
throw new \Exception("Account: [{$zone_entity->getParent()}] 정보를 찾을수 없습니다.");
}
$zone_service = new ZoneService();
$zone_entity = $zone_service->sync($account_entity, $zone_entity);
//해당 Zone의 Record reload작업한다
$record_service = new RecordService();
$record_service->reload($zone_entity);
//해당 Zone의 Firewall reload작업한다
$firewall_service = new FirewallService();
$firewall_service->reload($zone_entity);
log_message("debug", "AuditLog Process의 {$zone_entity->getTitle()} Sync및 Record,Firewall Reload 처리작업");
}
}