cfmgrv4/app/Controllers/Admin/Cloudflare/AccountController.php
2024-09-26 19:54:03 +09:00

65 lines
2.1 KiB
PHP

<?php
namespace App\Controllers\Admin\Cloudflare;
use App\Libraries\MyCloudflare\Account;
use App\Models\Cloudflare\AccountModel;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class AccountController extends CloudflareController
{
private $_myLibrary = null;
private $_model = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->class_name = "Account";
$this->class_path .= $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 getMyLibrary(): Account
{
if ($this->_myLibrary === null) {
$this->_myLibrary = new Account();
}
return $this->_myLibrary;
}
//생성
protected function create_init(): void
{
$this->action = 'create';
$this->fields = ['id', 'authkey'];
$this->filter_fields = [];
$this->field_rules = $this->getFormFieldRules();
$this->field_options = $this->getFormFieldOptions();
$this->getModel()->setAction($this->action);
}
protected function create_process(): void
{
parent::create_process();
$this->getMyLibrary()->create($this->formDatas);
}
// 리스트
public function list_init(): void
{
$this->action = 'index';
$this->fields = [$this->getModel()::TITLE, 'oldkey', 'type', 'status', 'updated_at', 'created_at'];
$this->filter_fields = ['type', 'status'];
$this->batchjob_fields = ['status'];
$this->field_rules = $this->getFormFieldRules();
$this->field_options = $this->getFormFieldOptions();
$this->getModel()->setAction($this->action);
}
}