Automation/app/Controllers/Cloudflare/AccountController.php
2024-09-24 17:09:29 +09:00

72 lines
2.3 KiB
PHP

<?php
namespace App\Controllers\Cloudflare;
use Psr\Log\LoggerInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\RedirectResponse;
use App\Libraries\MyCloudflare\Account;
use App\Entities\Cloudflare\AccountEntity;
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->layout = LAYOUTS['admin'];
$this->title = lang("{$this->class_name}.title");
helper($this->class_name);
}
final protected function getMyLibrary(): Account
{
if ($this->_myLibrary === null) {
$this->_myLibrary = new Account();
}
return $this->_myLibrary;
}
protected function create_init(): void
{
$this->fields = [$this->getMyLibrary()->getMyStorage()::TITLE, 'apikey', 'status'];
$this->filter_fields = ['status'];
$this->action = DB_ACTION['CREATE'];
$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();
}
protected function index_init(): void
{
$this->fields = [$this->getMyLibrary()->getMyStorage()::TITLE, 'apikey', 'status'];
$this->filter_fields = ['status'];
$this->action = DB_ACTION['CREATE'];
$this->getMyLibrary()->getMyStorage()->setAction($this->action);
helper(['form']);
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
}
public function index(): string
{
$this->create_init();
return parent::list_process();
}
}