cfmgrv4 init...1
This commit is contained in:
parent
a2f641edd0
commit
0672b0e1df
@ -10,10 +10,15 @@ use App\Entities\Cloudflare\AccountEntity;
|
|||||||
class Account extends MyCloudflare
|
class Account extends MyCloudflare
|
||||||
{
|
{
|
||||||
private $_myStorage = null;
|
private $_myStorage = null;
|
||||||
|
private $_authkey = "";
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
private function getRequest(): Guzzle
|
||||||
|
{
|
||||||
|
return $this->getMySocket()->request($this->_authkey);
|
||||||
|
}
|
||||||
final public function getMyStorage(): AccountModel
|
final public function getMyStorage(): AccountModel
|
||||||
{
|
{
|
||||||
if ($this->_myStorage === null) {
|
if ($this->_myStorage === null) {
|
||||||
@ -45,24 +50,39 @@ class Account extends MyCloudflare
|
|||||||
$formDatas['created_at'] = $result->created_on;
|
$formDatas['created_at'] = $result->created_on;
|
||||||
return $formDatas;
|
return $formDatas;
|
||||||
}
|
}
|
||||||
public function create(array $formDatas): AccountEntity
|
// public function create(array $formDatas): AccountEntity
|
||||||
|
// {
|
||||||
|
// //Socket용
|
||||||
|
// $cf = $this->getMySocket()->request($formDatas['authkey'])
|
||||||
|
// ->post('accounts', [
|
||||||
|
// 'name' => $formDatas[$this->getMyStorage()->getTitleField()],
|
||||||
|
// 'type' => $formDatas['type'],
|
||||||
|
// ]);
|
||||||
|
// $cf = json_decode($cf->getBody());
|
||||||
|
// if (!$cf->success) {
|
||||||
|
// throw new \Exception(__FUNCTION__ . "에서 실패:\n" . var_export($cf, true));
|
||||||
|
// }
|
||||||
|
// //Storage용
|
||||||
|
// $formDatas = $this->getArrayByResult($cf->result, $formDatas);
|
||||||
|
// $entity = $this->getMyStorage()->create($formDatas);
|
||||||
|
// log_message("notice", "Account::" . __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
||||||
|
// return $entity;
|
||||||
|
// }
|
||||||
|
public function create($formDatas): AccountEntity
|
||||||
{
|
{
|
||||||
//Socket용
|
$this->_authkey = $formDatas['authkey'];
|
||||||
$cf = $this->getMySocket()->request($formDatas['authkey'])
|
$cf = $this->getRequest()->get('accounts', ['page' => 1, 'per_page' => 20]);
|
||||||
->post('accounts', [
|
|
||||||
'name' => $formDatas[$this->getMyStorage()->getTitleField()],
|
|
||||||
'type' => $formDatas['type'],
|
|
||||||
]);
|
|
||||||
$cf = json_decode($cf->getBody());
|
$cf = json_decode($cf->getBody());
|
||||||
if (!$cf->success) {
|
if (!$cf->success) {
|
||||||
throw new \Exception(__FUNCTION__ . "에서 실패:\n" . var_export($cf, true));
|
throw new \Exception("Account:" . __FUNCTION__ . "에서 실패:\n" . var_export($cf, true));
|
||||||
}
|
}
|
||||||
//Storage용
|
//Account의 경우 인증키를 가지고있고 생성할수 없으므로 get으로 읽은후 첫번째것을 사용하기로 함
|
||||||
$formDatas = $this->getArrayByResult($cf->result, $formDatas);
|
$formDatas = $this->getArrayByResult(array_shift($cf->result));
|
||||||
$entity = $this->getMyStorage()->create($formDatas);
|
$entity = $this->$this->getMyStorage()->create($formDatas);
|
||||||
log_message("notice", "Account::" . __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
log_message("notice", "Account:" . __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function reload_entity($cf): AccountEntity
|
protected function reload_entity($cf): AccountEntity
|
||||||
{
|
{
|
||||||
return $this->getMyStorage()->modify(new AccountEntity, $this->getArrayByResult($cf));
|
return $this->getMyStorage()->modify(new AccountEntity, $this->getArrayByResult($cf));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user