cfmgrv3 init...3

This commit is contained in:
최준흠 2023-06-21 13:17:25 +09:00
parent 2b6e2e771a
commit d7a1032e15
3 changed files with 7 additions and 11 deletions

View File

@ -141,8 +141,12 @@ class ZoneController extends APIController
protected function delete_process($entity)
{
//Zone삭제전에 Record부터 삭제하기위함
$api = new \App\Libraries\Cloudflare\API\Record($entity);
$api->deleteByZone();
$recordModel = new \App\Models\Cloudflare\API\RecordModel();
$records = $recordModel->where($recordModel::PARENT_FIELD, $entity->getPrimaryKey())->findAll();
foreach ($records as $record) {
$api = new \App\Libraries\Cloudflare\API\Record($entity);
$api->delete($record);
}
$api = new Zone($this->getAccountModel()->getEntity($entity->getParentFieldData()));
$api->delete($entity);
return parent::delete_process($entity);

View File

@ -357,6 +357,7 @@ class CommonController extends BaseController
$entity = $this->_model->getEntity($uid);
$message = "";
try {
$this->delete_process($entity);
$message = "{$entity->getTitle()} " . __FUNCTION__ . " 완료하였습니다.";
Log::save("{$this->_viewDatas['title']} {$message}");
return alert_CommonHelper($message, session()->get(RETURN_URL));

View File

@ -87,15 +87,6 @@ class Record extends API
}
return $this->getEntityByResult($cfResult->result);
}
//Zone삭제전에 Record부터 삭제하기위함
public function deleteByZone()
{
$records = $this->_model->where($this->_model::PARENT_FIELD, $this->getParent()->getPrimaryKey())->findAll();
foreach ($records as $record) {
$this->delete($record);
$this->_model->delete($record->getPrimaryKey());
}
}
public function delete(\App\Entities\Cloudflare\API\RecordEntity $entity)
{
$cfResult = $this->getAdapter()->delete('zones/' . $this->getParent()->getPrimaryKey() . '/dns_records/' . $entity->getPrimaryKey());