Created
July 25, 2018 12:49
-
-
Save aynm142/467cdf07a1bb30120469f2646a371d37 to your computer and use it in GitHub Desktop.
facepalm.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function pnrAddMultiElements11(Request $request) | |
{ | |
$params = new SimpleXMLElement('<PNR_AddMultiElements></PNR_AddMultiElements>'); | |
$params->addChild('pnrActions'); | |
$params->pnrActions->addChild('optionCode'); | |
$params->pnrActions->optionCode = '0'; | |
foreach ($request->get('travellers') as $traveller) { | |
$params->addChild('travellerInfo'); | |
$params = $params->asXML(); | |
$travellerInfo = new SimpleXMLElement('<travellerInfo></travellerInfo>'); | |
$travellerInfo->addChild('elementManagementPassenger'); | |
$travellerInfo->elementManagementPassenger->addChild('segmentName'); | |
$travellerInfo->elementManagementPassenger->segmentName = 'NM'; | |
$travellerInfo->addChild('passengerData'); | |
$travellerInfo->passengerData->addChild('travellerInformation'); | |
// Traveller Information | |
$travellerInformation = $travellerInfo->passengerData->travellerInformation; | |
$travellerInformation->addChild('traveller'); | |
$travellerInformation->traveller->addChild('surname'); | |
$travellerInformation->traveller->surname = $traveller['lastName']; | |
$travellerInformation->addChild('passenger'); | |
$travellerInformation->passenger->addChild('firstName'); | |
$travellerInformation->passenger->firstName = $traveller['firstName']; | |
$travellerInformation->passenger->addChild('type'); | |
$travellerInformation->passenger->type = 'ADT'; | |
$travellerInfo = $travellerInfo->asXML(); | |
$travellerInfo = str_replace("<?xml version=\"1.0\"?>", "", $travellerInfo); | |
$params = str_replace('<travellerInfo/>', $travellerInfo, $params); | |
$params = simplexml_load_string($params); | |
} | |
// traveller info | |
$params->addChild('dataElementsMaster'); | |
$params->dataElementsMaster->addChild('marker1'); | |
$params->dataElementsMaster->addChild('data1'); | |
$params->dataElementsMaster->addChild('data2'); | |
$params->dataElementsMaster->addChild('data3'); | |
// first data element in div | |
$data1 = new SimpleXMLElement('<dataElementsIndiv></dataElementsIndiv>'); | |
$data1->addChild('elementManagementData'); | |
$data1->elementManagementData->addChild('reference'); | |
//data 1 reference | |
$reference1 = $data1->elementManagementData->reference; | |
$reference1->addChild('qualifier'); | |
$reference1->qualifier = 'OT'; | |
$reference1->addChild('number'); | |
$reference1->number = '1'; | |
$data1->elementManagementData->addChild('segmentName'); | |
$data1->elementManagementData->segmentName = 'AP'; | |
$data1->addChild('freetextData'); | |
$freetextData1 = $data1->freetextData; | |
$freetextData1->addChild('freetextDetail'); | |
$freetextData1->freetextDetail->addChild('subjectQualifier'); | |
$freetextData1->freetextDetail->subjectQualifier = '3'; | |
$freetextData1->freetextDetail->addChild('type'); | |
$freetextData1->freetextDetail->type = 'P02'; | |
$freetextData1->addChild('longFreetext'); | |
$freetextData1->longFreetext = $request->get('email'); | |
$data1 = $data1->asXML(); | |
$data1 = str_replace("<?xml version=\"1.0\"?>", "", $data1); | |
// second data element in div | |
$data2 = new SimpleXMLElement('<dataElementsIndiv></dataElementsIndiv>'); | |
$data2->addChild('elementManagementData'); | |
$elementManagementData2 = $data2->elementManagementData; | |
$elementManagementData2->addChild('reference'); | |
$elementManagementData2->reference->addChild('qualifier'); | |
$elementManagementData2->reference->qualifier = 'OT'; | |
$elementManagementData2->reference->addChild('number'); | |
$elementManagementData2->reference->number = '2'; | |
$elementManagementData2->addChild('segmentName'); | |
$elementManagementData2->segmentName = 'TK'; | |
$data2->addChild('ticketElement'); | |
// ticket element for data 2 | |
$ticketElement2 = $data2->ticketElement; | |
$ticketElement2->addChild('passengerType'); | |
$ticketElement2->passengerType = 'PAX'; | |
$ticketElement2->addChild('ticket'); | |
$ticketElement2->ticket->addChild('indicator'); | |
$ticketElement2->ticket->indicator = 'OK'; | |
$data2 = $data2->asXML(); | |
$data2 = str_replace("<?xml version=\"1.0\"?>", "", $data2); | |
// third data element in div | |
$data3 = new SimpleXMLElement('<dataElementsIndiv></dataElementsIndiv>'); | |
$data3->addChild('elementManagementData'); | |
$data3->elementManagementData->addChild('reference'); | |
$data3->elementManagementData->reference->addChild('qualifier'); | |
$data3->elementManagementData->reference->qualifier = 'OT'; | |
$data3->elementManagementData->reference->addChild('number'); | |
$data3->elementManagementData->reference->number = '4'; | |
$data3->elementManagementData->addChild('segmentName'); | |
$data3->elementManagementData->segmentName = 'RF'; | |
$data3->addChild('freetextData'); | |
$data3->freetextData->addChild('freetextDetail'); | |
$data3->freetextData->freetextDetail->addChild('subjectQualifier'); | |
$data3->freetextData->freetextDetail->subjectQualifier = '3'; | |
$data3->freetextData->freetextDetail->addChild('type'); | |
$data3->freetextData->freetextDetail->type = 'P22'; | |
$data3->freetextData->addChild('longFreetext'); | |
$data3->freetextData->longFreetext = 'Travel Bookster amabnl-amadeus-ws-client-1.8.0-dev'; | |
$data3 = $data3->asXML(); | |
$data3 = str_replace("<?xml version=\"1.0\"?>", "", $data3); | |
$params = $params->asXML(); | |
$params = str_replace("<?xml version=\"1.0\"?>", "", $params); | |
$params = str_replace('<data1/>', $data1, $params); | |
$params = str_replace('<data2/>', $data2, $params); | |
$params = str_replace('<data3/>', $data3, $params); | |
$params = str_replace('\n', '', $params); | |
dd($params); | |
return $params; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment