Пример #1
0
 /**
  * @param XmlSerializable $data
  * @return string
  */
 protected function buildMessage(XmlSerializable $data)
 {
     $this->writer->openMemory();
     $msgData = $this->buildMsgData($data);
     $this->writer->write([$this->rootEl => ['attributes' => $this->rootElAttributes, 'value' => $msgData]]);
     return $this->writer->outputMemory(true);
 }
Пример #2
0
 /**
  * @param $items
  * @return string
  */
 public function generateXML($items)
 {
     $this->writer->openMemory();
     $this->writer->startElement('properties');
     foreach ($items['data'] as $data) {
         $property = new Property();
         $property->propertyId = $data['property-id'];
         $property->dateListed = $data['date-listed'];
         $property->setPropertyType($data['property-type']);
         $property->setListingType($data['listing-type']);
         $property->link = $data['link'];
         $property->postalCode = $data['postal-code'];
         $property->city = $data['city'];
         $property->rooms = $data['rooms'];
         $property->bedrooms = $data['bedrooms'];
         $property->bathrooms = $data['bathrooms'];
         $property->propertySize = $data['property-size'];
         $property->landSize = $data['land-size'];
         $property->price = $data['price'];
         $property->images = $data['images'];
         $property->title = $data['title'];
         $property->description = $data['description'];
         $property->languages = $data['languages'];
         $this->writer->write(['property' => $property]);
     }
     $this->writer->endElement();
     return $this->writer->outputMemory();
 }
Пример #3
0
    function testSerialize()
    {
        $value = ['{http://sabredav.org/ns}elem1' => null, '{http://sabredav.org/ns}elem2' => 'textValue', '{http://sabredav.org/ns}elem3' => ['{http://sabredav.org/ns}elem4' => 'text2', '{http://sabredav.org/ns}elem5' => null], '{http://sabredav.org/ns}elem6' => 'text3'];
        $writer = new Writer();
        $writer->namespaceMap = ['http://sabredav.org/ns' => null];
        $writer->openMemory();
        $writer->startDocument('1.0');
        $writer->setIndent(true);
        $writer->write(['{http://sabredav.org/ns}root' => new KeyValue($value)]);
        $output = $writer->outputMemory();
        $expected = <<<XML
<?xml version="1.0"?>
<root xmlns="http://sabredav.org/ns">
 <elem1/>
 <elem2>textValue</elem2>
 <elem3>
  <elem4>text2</elem4>
  <elem5/>
 </elem3>
 <elem6>text3</elem6>
</root>

XML;
        $this->assertEquals($expected, $output);
    }
Пример #4
0
 /**
  * Prepare XML file based on AnalysisResult.
  * @param AnalysisResult $result analysis result object.
  * @return string XML contents.
  */
 protected function getXmlFor(AnalysisResult $result)
 {
     $writer = new Writer();
     $writer->openMemory();
     $writer->write($this->getSabreXmlArrayFor($result));
     return '<?xml version="1.0" encoding="UTF-8"?>' . $writer->outputMemory();
 }
Пример #5
0
 function write($input)
 {
     $writer = new Writer();
     $writer->contextUri = $this->contextUri;
     $writer->namespaceMap = $this->namespaceMap;
     $writer->openMemory();
     $writer->setIndent(true);
     $writer->write($input);
     return $writer->outputMemory();
 }
Пример #6
0
    function testSerialize()
    {
        $writer = new Writer();
        $writer->namespaceMap = ['http://sabredav.org/ns' => null];
        $writer->openMemory();
        $writer->startDocument('1.0');
        $writer->setIndent(true);
        $writer->write(['{http://sabredav.org/ns}root' => new Cdata('<foo&bar>')]);
        $output = $writer->outputMemory();
        $expected = <<<XML
<?xml version="1.0"?>
<root xmlns="http://sabredav.org/ns"><![CDATA[<foo&bar>]]></root>

XML;
        $this->assertEquals($expected, $output);
    }
Пример #7
0
 /**
  * Serializes a xCal or xCard object.
  *
  * @param Component $component
  *
  * @return string
  */
 static function writeXml(Component $component)
 {
     $writer = new Xml\Writer();
     $writer->openMemory();
     $writer->setIndent(true);
     $writer->startDocument('1.0', 'utf-8');
     if ($component instanceof Component\VCalendar) {
         $writer->startElement('icalendar');
         $writer->writeAttribute('xmlns', Parser\Xml::XCAL_NAMESPACE);
     } else {
         $writer->startElement('vcards');
         $writer->writeAttribute('xmlns', Parser\Xml::XCARD_NAMESPACE);
     }
     $component->xmlSerialize($writer);
     $writer->endElement();
     return $writer->outputMemory();
 }
Пример #8
0
    /**
     * @dataProvider xmlProvider
     */
    function testSerialize($expectedFallback, $input, $expected = null)
    {
        if (is_null($expected)) {
            $expected = $expectedFallback;
        }
        $writer = new Writer();
        $writer->namespaceMap = ['http://sabredav.org/ns' => null];
        $writer->openMemory();
        $writer->startDocument('1.0');
        //$writer->setIndent(true);
        $writer->write(['{http://sabredav.org/ns}root' => ['{http://sabredav.org/ns}fragment' => new XmlFragment($input)]]);
        $output = $writer->outputMemory();
        $expected = <<<XML
<?xml version="1.0"?>
<root xmlns="http://sabredav.org/ns"><fragment>{$expected}</fragment></root>
XML;
        $this->assertEquals($expected, $output);
    }
Пример #9
0
    function testSerialize()
    {
        $writer = new Writer();
        $writer->namespaceMap = ['http://sabredav.org/ns' => null];
        $writer->openMemory();
        $writer->startDocument('1.0');
        $writer->setIndent(true);
        $writer->contextUri = 'http://example.org/';
        $writer->write(['{http://sabredav.org/ns}root' => ['{http://sabredav.org/ns}uri' => new Uri('/foo/bar')]]);
        $output = $writer->outputMemory();
        $expected = <<<XML
<?xml version="1.0"?>
<root xmlns="http://sabredav.org/ns">
 <uri>http://example.org/foo/bar</uri>
</root>

XML;
        $this->assertEquals($expected, $output);
    }
Пример #10
0
 /**
  * @param \VirCom\ePUAP2\Requests\Login $request
  * @param \Sabre\Xml\Writer $xmlWriter
  */
 public function __construct(Requests\Login $request, Xml\Writer $xmlWriter)
 {
     $xmlWriter->openMemory();
     $xmlWriter->setIndent(true);
     $xmlWriter->startDocument();
     $xmlWriter->startElement('samlp:AuthnRequest');
     $xmlWriter->writeAttribute('xmlns:samlp', 'urn:oasis:names:tc:SAML:2.0:protocol');
     $xmlWriter->writeAttribute('ID', microtime(true));
     $xmlWriter->writeAttribute('IssueInstant', (new \DateTime())->format('Y-m-d\\TH:i:s\\Z'));
     $xmlWriter->writeAttribute('Version', '2.0');
     $xmlWriter->writeAttribute('Destination', $request->getUrl());
     $xmlWriter->writeAttribute('IsPassive', 'false');
     $xmlWriter->writeAttribute('AssertionConsumerServiceURL', $request->getResponseUrl());
     $xmlWriter->startElement('saml:Issuer');
     $xmlWriter->writeAttribute('xmlns:saml', 'urn:oasis:names:tc:SAML:2.0:assertion');
     $xmlWriter->write($request->getApplicationId());
     $xmlWriter->endElement();
     $xmlWriter->endElement();
     $this->parsedMessage = $xmlWriter->outputMemory();
 }
Пример #11
0
 /**
  * @param string $url
  * @param \VirCom\ePUAP2\Requests\Logout $request
  * @param \Sabre\Xml\Writer $xmlWriter
  */
 public function __construct(Requests\Logout $request, Xml\Writer $xmlWriter)
 {
     $xmlWriter->openMemory();
     $xmlWriter->setIndent(true);
     $xmlWriter->startDocument();
     $xmlWriter->startElement('samlp:LogoutRequest');
     $xmlWriter->writeAttribute('xmlns:samlp', 'urn:oasis:names:tc:SAML:2.0:protocol');
     $xmlWriter->writeAttribute('xmlns:saml', 'urn:oasis:names:tc:SAML:2.0:assertion');
     $xmlWriter->writeAttribute('ID', microtime(true));
     $xmlWriter->writeAttribute('IssueInstant', (new \DateTime())->format('Y-m-d\\TH:i:s\\Z'));
     $xmlWriter->writeAttribute('Version', '2.0');
     $xmlWriter->startElement('saml:Issuer');
     $xmlWriter->write($request->getApplicationId());
     $xmlWriter->endElement();
     $xmlWriter->startElement('samlp:NameID');
     $xmlWriter->write($request->getUsername());
     $xmlWriter->endElement();
     $xmlWriter->endElement();
     $this->parsedMessage = $xmlWriter->outputMemory();
 }
Пример #12
0
 /**
  * @dataProvider dataProvider
  */
 function testSerializers($notification, $expected1, $expected2)
 {
     $this->assertEquals('foo', $notification->getId());
     $this->assertEquals('"1"', $notification->getETag());
     $writer = new Writer();
     $writer->namespaceMap = ['http://calendarserver.org/ns/' => 'cs'];
     $writer->openMemory();
     $writer->startDocument('1.0', 'UTF-8');
     $writer->startElement('{http://calendarserver.org/ns/}root');
     $writer->write($notification);
     $writer->endElement();
     $this->assertXmlStringEqualsXmlString($expected1, $writer->outputMemory());
     $writer = new Writer();
     $writer->namespaceMap = ['http://calendarserver.org/ns/' => 'cs', 'DAV:' => 'd'];
     $writer->openMemory();
     $writer->startDocument('1.0', 'UTF-8');
     $writer->startElement('{http://calendarserver.org/ns/}root');
     $notification->xmlSerializeFull($writer);
     $writer->endElement();
     $this->assertXmlStringEqualsXmlString($expected2, $writer->outputMemory());
 }
Пример #13
0
    function testSerialize()
    {
        $value = ['{http://sabredav.org/ns}elem1', '{http://sabredav.org/ns}elem2', '{http://sabredav.org/ns}elem3', '{http://sabredav.org/ns}elem4', '{http://sabredav.org/ns}elem5', '{http://sabredav.org/ns}elem6'];
        $writer = new Writer();
        $writer->namespaceMap = ['http://sabredav.org/ns' => null];
        $writer->openMemory();
        $writer->startDocument('1.0');
        $writer->setIndent(true);
        $writer->write(['{http://sabredav.org/ns}root' => new Elements($value)]);
        $output = $writer->outputMemory();
        $expected = <<<XML
<?xml version="1.0"?>
<root xmlns="http://sabredav.org/ns">
 <elem1/>
 <elem2/>
 <elem3/>
 <elem4/>
 <elem5/>
 <elem6/>
</root>

XML;
        $this->assertEquals($expected, $output);
    }
Пример #14
0
 /**
  * @dataProvider dataProvider
  */
 function testSerializers($notification, $expected)
 {
     $notification = new InviteReply($notification);
     $this->assertEquals('foo', $notification->getId());
     $this->assertEquals('"1"', $notification->getETag());
     $simpleExpected = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:invite-reply/></cs:root>';
     $writer = new Writer();
     $writer->namespaceMap = ['http://calendarserver.org/ns/' => 'cs'];
     $writer->openMemory();
     $writer->startDocument('1.0', 'UTF-8');
     $writer->startElement('{http://calendarserver.org/ns/}root');
     $writer->write($notification);
     $writer->endElement();
     $this->assertEquals($simpleExpected, $writer->outputMemory());
     $writer = new Writer();
     $writer->contextUri = '/';
     $writer->namespaceMap = ['http://calendarserver.org/ns/' => 'cs', 'DAV:' => 'd'];
     $writer->openMemory();
     $writer->startDocument('1.0', 'UTF-8');
     $writer->startElement('{http://calendarserver.org/ns/}root');
     $notification->xmlSerializeFull($writer);
     $writer->endElement();
     $this->assertXmlStringEqualsXmlString($expected, $writer->outputMemory());
 }
Пример #15
0
 function writeFull($input)
 {
     $writer = new Writer();
     $writer->contextUri = '/';
     $writer->namespaceMap = $this->namespaceMap;
     $writer->openMemory();
     $writer->startElement('{http://calendarserver.org/ns/}root');
     $input->xmlSerializeFull($writer);
     $writer->endElement();
     return $writer->outputMemory();
 }
 public function exportXml()
 {
     $writer = new Writer();
     $writer->openMemory();
     $writer->startDocument();
     $writer->startElement('Document');
     $writer->writeAttribute('xmlns', 'urn:iso:std:iso:20022:tech:xsd:pain.001.001.03');
     $writer->setIndent(true);
     // header
     $writer->startElement('CstmrCdtTrfInitn');
     $writer->startElement('GrpHdr');
     $writer->writeElement('MsgId', $this->getMessageId());
     $writer->writeElement('CreDtTm', $this->getRequestDateTime());
     $writer->writeElement('NbOfTxs', $this->getPayaPaymentInfo()->getNumberOfPayments());
     $writer->writeElement('CtrlSum', $this->getPayaPaymentInfo()->getTotalTransactionsAmount());
     $writer->startElement('InitgPty');
     $writer->writeElement('Nm', $this->getPayaPaymentInfo()->getPayerName());
     $writer->endElement();
     $writer->endElement();
     // payment info
     $writer->startElement('PmtInf');
     $writer->writeElement('PmtInfId', $this->payaPaymentInfo->getPaymentInfoId());
     $writer->startElement('PmtMtd');
     $writer->writeAttribute('Ccy', 'IRR');
     $writer->write($this->payaPaymentInfo->getPaymentMethod());
     $writer->endElement();
     $writer->writeElement('NbOfTxs', $this->payaPaymentInfo->getNumberOfPayments());
     $writer->writeElement('CtrlSum', $this->payaPaymentInfo->getTotalTransactionsAmount());
     $writer->writeElement('ReqdExctnDt', $this->payaPaymentInfo->getRequestDate());
     $writer->startElement('Dbtr');
     $writer->writeElement('Nm', $this->payaPaymentInfo->getPayerName());
     $writer->endElement();
     $writer->startElement('DbtrAcct');
     $writer->startElement('Id');
     $writer->writeElement('IBAN', $this->payaPaymentInfo->getPayerIban());
     $writer->endElement();
     $writer->endElement();
     $writer->startElement('DbtrAgt');
     $writer->startElement('FinInstnId');
     $writer->writeElement('BIC', 'BMJIIRTHXXX');
     $writer->endElement();
     $writer->endElement();
     /** @var PayaPayment $payment */
     foreach ($this->payaPaymentInfo->getPayments() as $payment) {
         $writer->startElement('CdtTrfTxInf');
         $writer->startElement('PmtId');
         $writer->writeElement('InstrId', 'EMPTY');
         $writer->writeElement('EndToEndId', 'EMPTY');
         $writer->endElement();
         $writer->startElement('Amt');
         $writer->startElement('InstdAmt');
         $writer->writeAttribute('Ccy', 'IRR');
         $writer->write($payment->getAmount());
         $writer->endElement();
         $writer->endElement();
         $writer->startElement('Cdtr');
         $writer->writeElement('Nm', $payment->getCreditorName());
         $writer->endElement();
         $writer->startElement('CdtrAcct');
         $writer->startElement('Id');
         $writer->writeElement('IBAN', $payment->getCreditorIban());
         $writer->endElement();
         $writer->endElement();
         $writer->endElement();
     }
     $writer->endElement();
     $writer->endElement();
     $writer->endElement();
     $writer->endDocument();
     return $writer->outputMemory();
 }