when using XmlGeneratorFactory in your example we can not create a transfert credit
since $this->getDocumentPainMode() returns null
also be aware that getDocumentPainMode will never match the cases since it is set in setDocumentPainMode as a string representing the xml root element:
public function setDocumentPainMode($documentPainMode) {
$this->documentPainMode = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<Document
xmlns=\"urn:iso:std:iso:20022:tech:xsd:$documentPainMode\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:schemaLocation=\"urn:iso:std:iso:20022:tech:xsd:$documentPainMode $documentPainMode.xsd\"></Document>"; return $this; }
public function getDocumentPainMode() {
return $this->documentPainMode;
}
switch($this->getDocumentPainMode()) { // impossible to match the case
case self::PAIN_001_001_02: {
$documentMessage = "<CstmrCdtTrfInitn></CstmrCdtTrfInitn>";
break;
}
default: {
$documentMessage = "<CstmrDrctDbtInitn></CstmrDrctDbtInitn>";
break;
}
}
I quick fixed this by adding another enum
protected static $documentPainModeEnum;
public function setDocumentPainMode($documentPainMode) {
self::$documentPainModeEnum = $documentPainMode;
$this->documentPainMode = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
when using XmlGeneratorFactory in your example we can not create a transfert credit since $this->getDocumentPainMode() returns null also be aware that getDocumentPainMode will never match the cases since it is set in setDocumentPainMode as a string representing the xml root element:
I quick fixed this by adding another enum
then I switch like that: