Automation/app/Controllers/Cloudflare/Admin/AccountController.php
2024-09-19 23:19:54 +09:00

53 lines
1.6 KiB
PHP

<?php
namespace App\Controllers\Cloudflare\Admin;
use Psr\Log\LoggerInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\HTTP\RequestInterface;
use App\Libraries\MyStorage\AccountStorage;
use App\Libraries\MySocket\Cloudflare\AccountSocket;
use App\Controllers\Cloudflare\MyCloudflare;
use App\Traits\AuthTrait;
class AccountController extends MyCloudflare
{
use AuthTrait;
private $_email = "";
private $_api_key = "";
private $_mySocket = null;
private $_myStorage = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->session = $this->loginCheck_AuthTrait();
}
final protected function getMySocket(): AccountSocket
{
if ($this->_mySocket === null) {
$this->_mySocket = new AccountSocket($this->_email, $this->_api_key);
}
return $this->_mySocket;
}
final protected function getMyStorage(): AccountStorage
{
if ($this->_myStorage === null) {
$this->_myStorage = new AccountStorage();
}
return $this->_myStorage;
}
public function create(): void
{
$this->_email = $this->request->getVar('email');
$this->_api_key = $this->request->getVar('key');
//전송
$result = $this->getMySocket()->create($this->_email);
$formDatas = [];
$formDatas['key'] = $this->_api_key;
$entity = $this->getMyStorage()->create_process($result, $formDatas);
log_message("notice", __FUNCTION__ . "=> 작업을 완료하였습니다.");
}
}