<?php
 namespace App\Config; class Services_OfferConfirmations extends XmlBasicAbstract { protected $fileName=CONFIG_FILE_SERVICE_OFFER_CONFIRMATIONS; protected function getAll_rawData_extractDataFromFile(\SimpleXMLElement $xml) { $result=[]; foreach($xml->service as $serviceOfferDetails) { $serviceOfferConfirmationsList = []; $serviceOfferConfirmationsList['offerConfirmationMode'] = (string)$serviceOfferDetails->offerConfirmationMode; $result[(string)$serviceOfferDetails['code']]=$serviceOfferConfirmationsList; } return $result; } protected function save_check(){ foreach (Services_Basic::getAdmin()->getListLinear() as $serviceCode => $serviceDetails) { if ( !in_array($this->itemsList[$serviceCode]['offerConfirmationMode'], ['alwaysConfirmed', 'defaultConfirmed', 'defaultNotConfirmed'])) { $this->addErrorMessage('When setting the service offer details, the offer `confirmation mode` is not valid for service `'.$serviceDetails['name'].'`.'); } } } protected function save_write_do_getXml() { $xml=simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?><offerConfirmations />'); foreach (Services_Basic::getAdmin()->getListLinear() as $serviceCode => $serviceDetails) { $serviceObj=$xml->addChild('service'); $serviceObj['code']=$serviceCode; $serviceObj->offerConfirmationMode = $this->itemsList[$serviceCode]['offerConfirmationMode']; } return $xml; } } 