/** * Set integration data to configuration file. * * @param Integration $integration * @return void */ protected function setConfiguration(Integration $integration) { $fileConfig = MTF_BP . '/etc/config.xml'; $dom = new \DOMDocument(); if (!file_exists($fileConfig)) { copy(MTF_BP . '/etc/config.xml.dist', $fileConfig); } $dom->load($fileConfig); $webapiToken = (new \DOMXPath($dom))->query('//config/handler/webapi/token')->item(0); if ($webapiToken) { $webapiToken->nodeValue = $integration->getToken(); } else { $webapi = (new \DOMXPath($dom))->query('//config/handler/webapi')->item(0); $webapi->appendChild($dom->createElement('token', $integration->getToken())); } $dom->save($fileConfig); $this->configuration = $this->objectManager->create('Magento\\Mtf\\Config\\DataInterface'); }