/** * @param array $data * @param array $details * @return void */ private function saveContactInfos($data, $details) { $this->_config->saveConfig('linkstate', 'linked'); $this->_config->saveConfig('accountId', $data['id']); $this->_config->saveConfig('customerLogo', $data['customer']['logo']); $this->_config->saveConfig('companyLogo', $data['agency']['logo']); $this->_config->saveConfig('accountUserName', $data['firstName'] . ' ' . $data['lastName']); $this->_config->saveConfig('accountName', $data['customer']['name']); $this->_config->saveConfig('lastAuth', date('d.n.Y')); $this->_config->saveConfig('accountEmail', $details['email']); if ($details['expire']['isdefined']) { $this->_config->saveConfig('accountExpire', $details['expire']['value']); } }
/** * @return bool */ public function populateFields() { $this->_getResource()->createTableFields(); $this->_getResource()->flushFields(); /* Make REST request */ $result = $this->_rest->get('fields/'); /* Check if everything went fine or lock down the module*/ if ($result['info']['http_code'] < 200 || $result['info']['http_code'] > 299) { $this->cfg->saveConfig('linkstate', 'unvalid'); return false; } /* Populate DB */ $tab = $result['result']; foreach ($tab as $elem) { $this->saveFields(['id' => $elem['id'], 'name' => $elem['name'], 'isUnicity' => $elem['isUnicity'], 'type' => $elem['type']]); } return true; }
/** * @return bool */ public function populateSegments() { $this->_getResource()->createTableSegments(); $this->_getResource()->flushSegments(); /* Make REST request */ $result = $this->_rest->get('segments/'); /* Check if everything went fine or lock down the module*/ if ($result['info']['http_code'] < 200 || $result['info']['http_code'] > 299) { $this->cfg->saveConfig('linkstate', 'unvalid'); return false; } /* Populate DB */ $tab = $result['result']; foreach ($tab as $elem) { if ($elem['type'] == 'static') { $this->saveSegments($elem['id'], $elem['name']); } } return true; }
/** * @return bool */ private function checkAndSave() { $toSave = $this->getRequest()->getPostValue(); /* Check if settings are valid for API calls, returning an error if anything goes wrong*/ $integrity = $this->checkIntegrity($toSave); /* Check if there is an error and then return it */ if ($integrity['haveError']) { $this->messageManager->addError($integrity['message']); return false; } /* Since we're fine, let's save. */ $event = $this->getRequest()->getParam('form') . '/'; foreach ($toSave as $key => $result) { if ($key != 'form_key') { $this->_config->saveConfig($event . $key, $result); } } $this->messageManager->addSuccess(__('Saved !')); return true; }