cfmgrv4 init...2

This commit is contained in:
최준흠 2024-10-12 00:07:14 +09:00
parent f051e0ae11
commit a7ff8e6ebd
3 changed files with 37 additions and 50 deletions

View File

@ -13,7 +13,6 @@ use Psr\Log\LoggerInterface;
class AccountController extends CloudflareController
{
private $_myLibrary = null;
private $_model = null;
private $_auth_entity = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
@ -21,8 +20,8 @@ class AccountController extends CloudflareController
parent::initController($request, $response, $logger);
$this->class_name = "Account";
$this->class_path .= $this->class_name;
$this->title = lang("{$this->class_path}.title");
$this->helper = new AccountHelper();
$this->title = lang("{$this->class_path}.title");
$this->helper = new AccountHelper();
}
final protected function getModel(): AccountModel
{
@ -33,10 +32,7 @@ class AccountController extends CloudflareController
}
final protected function getMyLibrary(): Account
{
if ($this->_myLibrary === null) {
$this->_myLibrary = new Account($this->_auth_entity);
}
return $this->_myLibrary;
return new Account($this->_auth_entity);
}
protected function getFormFieldOption(string $field, array $options = []): array
{
@ -56,22 +52,22 @@ class AccountController extends CloudflareController
// 리스트
public function index(): string
{
$this->action = __FUNCTION__;
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'type', 'status', 'updated_at', 'created_at'];
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'status'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
$this->action = __FUNCTION__;
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'type', 'status', 'updated_at', 'created_at'];
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'status'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
$this->batchjob_fields = [];
return $this->list_procedure();
}
// Download
public function download(string $output_type, $uid = false): DownloadResponse|string
{
$this->action = __FUNCTION__;
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'type', 'status', 'updated_at', 'created_at'];
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'status'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
$this->action = __FUNCTION__;
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'type', 'status', 'updated_at', 'created_at'];
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'status'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
$this->batchjob_fields = ['type', 'status'];
return $this->download_procedure($output_type, $uid);
}

View File

@ -13,15 +13,14 @@ use Psr\Log\LoggerInterface;
class RecordController extends CloudflareController
{
private $_myLibrary = null;
private $_zone_entity = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->class_name .= "Record";
$this->class_path .= $this->class_name;
$this->title = lang("{$this->class_path}.title");
$this->helper = new RecordHelper();
$this->title = lang("{$this->class_path}.title");
$this->helper = new RecordHelper();
}
final protected function getModel(): RecordModel
{
@ -32,10 +31,7 @@ class RecordController extends CloudflareController
}
final protected function getMyLibrary(): Record
{
if ($this->_myLibrary === null) {
$this->_myLibrary = new Record($this->_zone_entity);
}
return $this->_myLibrary;
return new Record($this->_zone_entity);
}
protected function getFormFieldOption(string $field, array $options = []): array
{
@ -70,9 +66,9 @@ class RecordController extends CloudflareController
}
private function init(string $action): void
{
$this->action = $action;
$this->fields = [$this->getModel()::PARENT, 'type', 'content', 'proxied', 'hosts'];
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->action = $action;
$this->fields = [$this->getModel()::PARENT, 'type', 'content', 'proxied', 'hosts'];
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'proxied'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
}
@ -95,7 +91,7 @@ class RecordController extends CloudflareController
$this->create_validate($this->action, $this->fields);
$this->formDatas = $this->getFormDatas();
//부모데이터정의
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]);
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]);
//데이터 검증
$cnt = 1;
foreach ($this->formDatas['hosts'] as $host) {
@ -143,9 +139,9 @@ class RecordController extends CloudflareController
//일괄처리작업
public function batcjob(): RedirectResponse
{
$this->action = __FUNCTION__;
$this->fields = ['proxied'];
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->action = __FUNCTION__;
$this->fields = ['proxied'];
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
return $this->batcjob_procedure();
}
//Sync작업
@ -175,29 +171,29 @@ class RecordController extends CloudflareController
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
}
//부모데이터정의
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]);
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]);
//Cloudflare 삭제
$this->entity = $this->getMyLibrary()->delete($this->entity);
}
// 리스트
public function index(): string
{
$this->action = __FUNCTION__;
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'type', 'content', 'ttl', 'proxied', 'locked', 'updated_at', 'created_at'];
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'proxied', 'fixed'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
$this->action = __FUNCTION__;
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'type', 'content', 'ttl', 'proxied', 'locked', 'updated_at', 'created_at'];
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'proxied', 'fixed'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
$this->batchjob_fields = ['proxied'];
return $this->list_procedure();
}
// Download
public function download(string $output_type, $uid = false): DownloadResponse|string
{
$this->action = __FUNCTION__;
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'type', 'content', 'ttl', 'proxied', 'locked', 'updated_at', 'created_at'];
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'proxied'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
$this->action = __FUNCTION__;
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'type', 'content', 'ttl', 'proxied', 'locked', 'updated_at', 'created_at'];
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'proxied'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
$this->batchjob_fields = ['proxied'];
return $this->download_procedure($output_type, $uid);
}

View File

@ -2,7 +2,6 @@
namespace App\Controllers\Admin\Cloudflare;
use App\Entities\Cloudflare\RecordEntity;
use App\Helpers\Cloudflare\ZoneHelper;
use App\Libraries\Cloudflare\Record;
use App\Libraries\Cloudflare\Zone;
@ -15,7 +14,6 @@ use Psr\Log\LoggerInterface;
class ZoneController extends CloudflareController
{
private $_myLibrary = null;
private $_account_entity = null;
private $_model = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
@ -23,8 +21,8 @@ class ZoneController extends CloudflareController
parent::initController($request, $response, $logger);
$this->class_name .= "Zone";
$this->class_path .= $this->class_name;
$this->title = lang("{$this->class_path}.title");
$this->helper = new ZoneHelper();
$this->title = lang("{$this->class_path}.title");
$this->helper = new ZoneHelper();
}
final protected function getModel(): ZoneModel
{
@ -35,10 +33,7 @@ class ZoneController extends CloudflareController
}
final protected function getMyLibrary(): Zone
{
if ($this->_myLibrary === null) {
$this->_myLibrary = new Zone($this->_account_entity);
}
return $this->_myLibrary;
return new Zone($this->_account_entity);
}
protected function getFormFieldOption(string $field, array $options = []): array
{