cfmgrv4/app/Controllers/Admin/Cloudflare/AccountController.php
2024-09-25 19:45:42 +09:00

71 lines
2.5 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\Libraries\MyCloudflare\Account;
class AccountController extends CloudflareController
{
private $_myLibrary = 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 getMyLibrary(): Account
{
if ($this->_myLibrary === null) {
$this->_myLibrary = new Account();
}
return $this->_myLibrary;
}
protected function create_init(): void
{
$this->action = 'create';
$this->fields = [$this->getMyLibrary()->getMyStorage()::TITLE, 'authkey', 'type', 'status'];
$this->filter_fields = ['type', 'status'];
$this->field_rules = $this->getFormFieldRules();
$this->field_options = $this->getFormFieldOptions();
$this->getMyLibrary()->getMyStorage()->setAction($this->action);
}
// public function create_form(): RedirectResponse|string
// {
// $this->create_init();
// return $this->create_form_process();
// }
protected function create_process_submit(): void
{
$entity = $this->getMyLibrary()->create($this->formDatas);
}
public function create(): RedirectResponse
{
$this->create_init();
$this->formDatas = [];
$this->getFormDatas();
$this->convertFormDatas();
$this->validateFormDatas();
return parent::create_process();
}
public function index(): string
{
$this->action = 'index';
$this->fields = [$this->getMyLibrary()->getMyStorage()::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->getMyLibrary()->getMyStorage()->setAction($this->action);
helper(['form']);
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
return parent::list_process();
}
}