<?php
 namespace App\Config; class SupplierInvoice_Services extends XmlBasicAbstract { protected $fileName=CONFIG_FILE_SUPPLIERINVOICES_SERVICES; protected function getAll_rawData_extractDataFromFile(\SimpleXMLElement $xml) { $allServList=Services_Basic::getInstance()->getListLinear(); $disabledServ=[]; foreach($xml->service as $serv) { $servCode=(String)$serv['code']; $disabled=(Int)$serv['disabled']; if ($disabled) $disabledServ[$servCode]=true; } $return=[]; foreach($allServList as $servCode=>$nothing) { if ($disabledServ[$servCode]) $return[$servCode]=false; else $return[$servCode]=true; } return $return; } protected function getAll_rawData_fileNotExists() { $return=[]; foreach(Services_Basic::getInstance()->getListLinear() as $servCode=>$nothing) { $return[$servCode]=true; } return $return; } protected function save_check() { foreach($this->itemsList as $code=>$nothing) { if (!Services_Basic::getInstance()->checkService($code)) $this->addErrorMessage(sprintf('The service code `%s` is not valid.', $code)); } } protected function save_write_do_getXml() { $xml=simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?><supplierInvoiceServices/>'); $allServList=Services_Basic::getInstance()->getListLinear(); foreach($allServList as $serviceCode=>$nothing) { if (!$this->itemsList[$serviceCode]) { $servObj=$xml->addChild('service'); $servObj['code']=$serviceCode; $servObj['disabled']=true; } } return $xml; } } 