session = $this->session_AuthTrait(); $this->class_name = 'Zone'; helper($this->class_name); } final protected function getMySocket(): CloudflareSocket { if ($this->_mySocket === null) { $this->_mySocket = new CloudflareSocket(); } return $this->_mySocket; } final protected function getModel(): ZoneModel { if ($this->_model === null) { $this->_model = new ZoneModel(); } return $this->_model; } protected function create_init(): void { $this->fields = ['id', 'apikey']; $this->filter_fields = ['status']; $this->action = 'create'; $this->getModel()->setAction($this->action); } public function create_form(): RedirectResponse|string { return $this->create_form_process(); } //Result 형태 // [ // {"id":"078e88a7735965b661715af13031ecb0", // "name":"Cloudwin002@idcjp.jp's Auth", // "type":"standard", // "settings":{ // "enforce_twofactor":false, // "api_access_enabled":null, // "access_approval_expiry":null, // "use_account_custom_ns_by_default":false // }, // "legacy_flags":{"enterprise_zone_quota":{"maximum":0,"current":0,"available":0}}, // "created_on":"2017-06-26T05:44:49.470184Z"} // ] protected function create_process_submit(): ZoneEntity { $this->getMySocket()->setAPIKey($this->formDatas['apikey']); $result = $this->getMySocket()->getZone()->addZone($this->formDatas['id']); $this->formDatas[$this->getModel()->PK()] = $result->id; $this->formDatas[$this->getModel()->getTitleField()] = $result->name; $this->formDatas['type'] = $result->type; $this->formDatas['status'] = 'use'; $this->formDatas['updated_at'] = $result->created_on; $this->formDatas['created_at'] = $result->created_on; return $this->getModel()->create($this->formDatas); } public function create(): RedirectResponse { return parent::create_process(); } }