cfmgrv4 init...4

This commit is contained in:
최준흠 2024-10-29 17:02:53 +09:00
parent a125846187
commit f95318aeb6
4 changed files with 14 additions and 35 deletions

View File

@ -69,15 +69,6 @@ class RecordController extends CloudflareController
$this->$parent_field = $this->request->getVar($parent_field) ?: DEFAULTS["EMPTY"];
return $this->create_form_procedure();
}
protected function create_validate(string $action, array $fields): array
{
//hosts를 제외한 fields Valid처리
return parent::create_validate($action, array_diff($fields, ['hosts']));
}
private function setEntitys(array $entitys): void
{
$this->entitys = $entitys;
}
protected function create_process(): void
{
//DB작업도 Socket에서 다 처리하므로 parent::create_process()하면 않됨
@ -112,10 +103,9 @@ class RecordController extends CloudflareController
$this->formDatas['content'],
$this->formDatas['proxied']
);
log_message("debug", message: "Record:{$entity->getTitle()} 생성 작업을 완료하였습니다.");
$entitys[] = $entity;
}
$this->setEntitys($entitys); // 새로운 메서드를 사용하여 entitys 설정
$this->entitys = $entitys;
}
protected function create_process_result(): RedirectResponse|string
{

View File

@ -76,15 +76,6 @@ class ZoneController extends CloudflareController
$this->$parent_field = $this->request->getVar($parent_field) ?: DEFAULTS["EMPTY"];
return $this->create_form_procedure();
}
protected function create_validate(string $action, array $fields): array
{
//domains,hosts를 제외한 fields Valid처리
return parent::create_validate($action, array_diff($fields, ['domains', 'hosts']));
}
private function setEntitys(array $entitys): void
{
$this->entitys = $entitys;
}
protected function create_process(): void
{
//DB작업도 Socket에서 다 처리하므로 parent::create_process()하면 않됨
@ -130,33 +121,27 @@ class ZoneController extends CloudflareController
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]);
//Zone생성
$cnt = 1;
$zone_entitys = [];
$entitys = [];
foreach ($this->formDatas['domains'] as $domain) {
$entity = $this->getService()->create($this->_account_entity, $domain);
log_message("debug", "Zone:{$entity->getTitle()} 작업을 완료하였습니다.");
$zone_entitys[] = $entity;
$entitys[] = $entity;
$cnt++;
}
//Record생성
$entitys = [];
foreach ($zone_entitys as $zone_entity) {
foreach ($entitys as $entity) {
$entity->records = [];
$record = new RecordService();
$record_entitys = [];
foreach ($this->formDatas['hosts'] as $host) {
$entity = $record->create(
$zone_entity,
$entity->records[] = $record->create(
$entity,
$host,
$this->formDatas['type'],
$this->formDatas['content'],
$this->formDatas['proxied']
);
log_message("debug", "Record:{$entity->getTitle()} 작업을 완료하였습니다.");
$record_entitys[] = $entity;
}
$zone_entity->records = $record_entitys;
$entitys[] = $zone_entity;
}
$this->setEntitys($entitys);
$this->entitys = $entitys;
}
protected function create_process_result(): RedirectResponse|string
{

View File

@ -84,7 +84,9 @@ class RecordService extends CloudflareService
$response = $this->getMySocket()->post("zones/{$this->getParentEntity()->getPK()}/dns_records", $datas);
$body = json_decode($response->getBody());
//DB생성
return $this->getModel()->create($this->getArrayByResult($body->result));
$entity = $this->getModel()->create($this->getArrayByResult($body->result));
log_message("debug", "Record:{$entity->getTitle()} 작업을 완료하였습니다.");
return $entity;
}
public function modify(ZoneEntity $parent_entity, RecordEntity $entity, array $formDatas): RecordEntity
{

View File

@ -124,7 +124,9 @@ class ZoneService extends CloudflareService
//초기화값 추가셋팅 ipv6 , development_mode , security_level
$formDatas[$field] = $this->setCFSetting($formDatas[ZoneModel::PK], $field, $default);
}
return $this->getModel()->create($formDatas);
$entity = $this->getModel()->create($formDatas);
log_message("debug", "Zone:{$entity->getTitle()} 작업을 완료하였습니다.");
return $entity;
}
public function modify(AccountEntity $parent_entity, ZoneEntity $entity, array $formDatas): ZoneEntity
{