79 lines
2.8 KiB
PHP
79 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Admin\Cloudflare;
|
|
|
|
use Psr\Log\LoggerInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\RedirectResponse;
|
|
use App\Models\Cloudflare\AccountModel;
|
|
use App\Libraries\MySocket\Cloudflare\ZoneSocket;
|
|
use App\Libraries\MySocket\Cloudflare\AccountSocket;
|
|
|
|
class AccountController extends CloudflareController
|
|
{
|
|
private $_mySocket = null;
|
|
private $_model = null;
|
|
private $_auth_key = null;
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
$this->class_name = "Account";
|
|
$this->class_path = $this->root . $this->class_name;
|
|
$this->title = lang("{$this->class_path}.title");
|
|
helper($this->class_path);
|
|
}
|
|
final protected function getModel(): AccountModel
|
|
{
|
|
if ($this->_model === null) {
|
|
$this->_model = new AccountModel();
|
|
}
|
|
return $this->_model;
|
|
}
|
|
final protected function getMySocket(): AccountSocket
|
|
{
|
|
if ($this->_mySocket === null) {
|
|
$this->_mySocket = new AccountSocket($this->_auth_key);
|
|
}
|
|
return $this->_mySocket;
|
|
}
|
|
protected function getFormFieldOption(string $field, array $options = []): array
|
|
{
|
|
switch ($field) {
|
|
case $this->getModel()::PARENT:
|
|
// $this->getAuthModel()->where('status', DEFAULTS['STATUS']);
|
|
$options[$field] = $this->getAuthModel()->getFormFieldOption($field);
|
|
// echo $this->getAuthModel()->getLastQuery();
|
|
// dd($options);
|
|
break;
|
|
default:
|
|
$options = parent::getFormFieldOption($field, $options);
|
|
break;
|
|
}
|
|
return $options;
|
|
}
|
|
// 리스트
|
|
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->batchjob_fields = ['typep', 'status'];
|
|
return $this->list_procedure();
|
|
}
|
|
//Zone Reload By Account
|
|
protected function reload_process(): void
|
|
{
|
|
foreach ($this->getModel()->getEntitys as $entity) {
|
|
$zone_socket = new ZoneSocket($entity);
|
|
$zone_socket->reload();
|
|
}
|
|
}
|
|
public function reload(): RedirectResponse
|
|
{
|
|
return $this->reload_procedure();
|
|
}
|
|
}
|