예제 #1
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();
 }
예제 #2
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);
 }
예제 #3
0
    /**
     * The xmlSerialize metod is called during xml writing.
     *
     * Use the $writer argument to write its own xml serialization.
     *
     * An important note: do _not_ create a parent element. Any element
     * implementing XmlSerializble should only ever write what's considered
     * its 'inner xml'.
     *
     * The parent of the current element is responsible for writing a
     * containing element.
     *
     * This allows serializers to be re-used for different element names.
     *
     * If you are opening new elements, you must also close them again.
     *
     * @param Writer $writer
     * @return void
     */
    function xmlSerialize(Writer $writer) {

        foreach ($this->properties as $propertyName => $propertyValue) {

            if (is_null($propertyValue)) {
                $writer->write(['{DAV:}remove' => [$propertyName => $propertyValue]]);
            } else {
                $writer->write(['{DAV:}set' => [$propertyName => $propertyValue]]);
            }

        }

    }
예제 #4
0
 /**
  * The xmlSerialize metod is called during xml writing.
  *
  * Use the $writer argument to write its own xml serialization.
  *
  * An important note: do _not_ create a parent element. Any element
  * implementing XmlSerializble should only ever write what's considered
  * its 'inner xml'.
  *
  * The parent of the current element is responsible for writing a
  * containing element.
  *
  * This allows serializers to be re-used for different element names.
  *
  * If you are opening new elements, you must also close them again.
  *
  * @param Writer $writer
  * @return void
  */
 function xmlSerialize(Writer $writer)
 {
     foreach ($this->properties as $propertyName => $propertyValue) {
         if (is_null($propertyValue)) {
             $writer->startElement("{DAV:}remove");
             $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]);
             $writer->endElement();
         } else {
             $writer->startElement("{DAV:}set");
             $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]);
             $writer->endElement();
         }
     }
 }
예제 #5
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);
    }
예제 #6
0
 /**
  * @param Writer $writer
  * @return void
  */
 function xmlSerialize(Writer $writer)
 {
     // This is required
     $writer->write(['loc' => $this->location]);
     // This is optional
     $this->add($writer, ['lastmod']);
 }
예제 #7
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();
 }
예제 #8
0
파일: Common.php 프로젝트: laravelista/bard
 /**
  * Adds property from properties to url if it is not null.
  *
  * @param Writer $writer
  * @param array $properties
  */
 private function add(Writer $writer, array $properties)
 {
     foreach ($properties as $property) {
         if (!is_null($this->{$property})) {
             $writer->write([$property => $this->{$property}]);
         }
     }
 }
예제 #9
0
 /**
  * The xmlSerialize metod is called during xml writing.
  *
  * Use the $writer argument to write its own xml serialization.
  *
  * An important note: do _not_ create a parent element. Any element
  * implementing XmlSerializble should only ever write what's considered
  * its 'inner xml'.
  *
  * The parent of the current element is responsible for writing a
  * containing element.
  *
  * This allows serializers to be re-used for different element names.
  *
  * If you are opening new elements, you must also close them again.
  *
  * @param Writer $writer
  * @return void
  */
 function xmlSerialize(Writer $writer)
 {
     $productData = [$this->category => []];
     if ($this->productType) {
         $productData[$this->category] = ['ProductType' => [$this->productType => ['AdditionalDrives' => 'dvd', 'ComputerMemoryType' => 'sodimm', 'DisplayResolutionMaximum' => 'fullhd   ']]];
     }
     $writer->write(['MessageID' => 1, 'OperationType' => 'Update', 'Product' => ['SKU' => $this->sku, 'DescriptionData' => ['Title' => $this->title, 'Brand' => $this->brand, 'Description' => $this->description, 'MSRP' => ['attributes' => ['currency' => $this->currency], 'value' => $this->msrp]], 'ProductData' => $productData]]);
 }
예제 #10
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();
 }
예제 #11
0
파일: Logout.php 프로젝트: vircom/epuap2
 /**
  * @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
    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);
    }
예제 #13
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);
    }
예제 #14
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);
    }
예제 #15
0
파일: Login.php 프로젝트: vircom/epuap2
 /**
  * @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();
 }
예제 #16
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());
 }
예제 #17
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);
    }
예제 #18
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());
 }
예제 #19
0
 /**
  * The serialize method is called during xml writing.
  *
  * It should use the $writer argument to encode this object into XML.
  *
  * Important note: it is not needed to create the parent element. The
  * parent element is already created, and we only have to worry about
  * attributes, child elements and text (if any).
  *
  * Important note 2: If you are writing any new elements, you are also
  * responsible for closing them.
  *
  * @param Writer $writer
  * @return void
  */
 function xmlSerialize(Writer $writer)
 {
     $writer->write(HTTP\Util::toHTTPDate($this->time));
 }
예제 #20
0
파일: Eater.php 프로젝트: kalmas/sabre-xml
 /**
  * The serialize method is called during xml writing.
  *
  * It should use the $writer argument to encode this object into XML.
  *
  * Important note: it is not needed to create the parent element. The
  * parent element is already created, and we only have to worry about
  * attributes, child elements and text (if any).
  *
  * Important note 2: If you are writing any new elements, you are also
  * responsible for closing them.
  *
  * @param XML\Writer $writer
  * @return void
  */
 public function serializeXml(XML\Writer $writer)
 {
     $writer->startElement('{http://sabredav.org/ns}elem1');
     $writer->write('hiiii!');
     $writer->endElement();
 }
예제 #21
0
 /**
  * The xmlSerialize metod is called during xml writing.
  *
  * Use the $writer argument to write its own xml serialization.
  *
  * An important note: do _not_ create a parent element. Any element
  * implementing XmlSerializble should only ever write what's considered
  * its 'inner xml'.
  *
  * The parent of the current element is responsible for writing a
  * containing element.
  *
  * This allows serializers to be re-used for different element names.
  *
  * If you are opening new elements, you must also close them again.
  *
  * @param Writer $writer
  * @return void
  */
 function xmlSerialize(Xml\Writer $writer)
 {
     $writer->write($this->value);
 }
예제 #22
0
 /**
  * @param Writer $writer
  */
 private function addImages(Writer $writer)
 {
     $writer->startElement('images');
     foreach ($this->images as $image) {
         $writer->startElement('image');
         $writer->write($image);
         $writer->endElement();
     }
     $writer->endElement();
 }
예제 #23
0
 /**
  * Create IodefElement Objects to XML Elements
  * @param  SabreWriter $writer
  * @return void
  */
 public function xmlSerialize(SabreWriter $writer)
 {
     // Validate the attributes and value.
     if ($this->validate() === true) {
         // Start serializing all allowed child elements
         if (empty($this->elements)) {
             if (property_exists($this, 'value')) {
                 $writer->write($this->value);
             }
         } else {
             $writer->write($this->getChildren());
         }
     } else {
         die($this->getShortName() . ": Validation failed, see details above.");
     }
 }
예제 #24
0
 /**
  * This method serializes the data into XML. This is used to create xCard or
  * xCal documents.
  *
  * @param Xml\Writer $writer  XML writer.
  *
  * @return void
  */
 function xmlSerialize(Xml\Writer $writer)
 {
     $parameters = [];
     foreach ($this->parameters as $parameter) {
         if ($parameter->name === 'VALUE') {
             continue;
         }
         $parameters[] = $parameter;
     }
     $writer->startElement(strtolower($this->name));
     if (!empty($parameters)) {
         $writer->startElement('parameters');
         foreach ($parameters as $parameter) {
             $writer->startElement(strtolower($parameter->name));
             $writer->write($parameter);
             $writer->endElement();
         }
         $writer->endElement();
     }
     $this->xmlSerializeValue($writer);
     $writer->endElement();
 }
예제 #25
0
파일: Mock.php 프로젝트: sebbie42/casebox
 /**
  * The serialize method is called during xml writing.
  *
  * It should use the $writer argument to encode this object into XML.
  *
  * Important note: it is not needed to create the parent element. The
  * parent element is already created, and we only have to worry about
  * attributes, child elements and text (if any).
  *
  * Important note 2: If you are writing any new elements, you are also
  * responsible for closing them.
  *
  * @param Xml\Writer $writer
  * @return void
  */
 function xmlSerialize(Xml\Writer $writer)
 {
     $writer->startElement('{http://sabredav.org/ns}elem1');
     $writer->write('hiiii!');
     $writer->endElement();
 }
예제 #26
0
파일: Url.php 프로젝트: laravelista/bard
 /**
  * @param Writer $writer
  */
 private function addTranslations(Writer $writer)
 {
     foreach ($this->translations as $translation) {
         $writer->write([['name' => 'xhtml:link', 'attributes' => ['rel' => 'alternate', 'hreflang' => $translation['hreflang'], 'href' => $translation['href']], 'value' => null]]);
     }
 }
예제 #27
0
 function xmlSerialize(Writer $writer)
 {
     $writer->write(['name' => $this->name, 'description' => $this->description]);
 }
예제 #28
0
 /**
  * This method serializes the data into XML. This is used to create xCard or
  * xCal documents.
  *
  * @param Xml\Writer $writer  XML writer.
  *
  * @return void
  */
 function xmlSerialize(Xml\Writer $writer)
 {
     $propertiesByGroup = [];
     foreach ($this->children() as $property) {
         $group = $property->group;
         if (!isset($propertiesByGroup[$group])) {
             $propertiesByGroup[$group] = [];
         }
         $propertiesByGroup[$group][] = $property;
     }
     $writer->startElement(strtolower($this->name));
     foreach ($propertiesByGroup as $group => $properties) {
         if (!empty($group)) {
             $writer->startElement('group');
             $writer->writeAttribute('name', strtolower($group));
         }
         foreach ($properties as $property) {
             switch ($property->name) {
                 case 'VERSION':
                     continue;
                 case 'XML':
                     $value = $property->getParts();
                     $fragment = new Xml\Element\XmlFragment($value[0]);
                     $writer->write($fragment);
                     break;
                 default:
                     $property->xmlSerialize($writer);
                     break;
             }
         }
         if (!empty($group)) {
             $writer->endElement();
         }
     }
     $writer->endElement();
 }
예제 #29
0
파일: Base.php 프로젝트: kalmas/sabre-xml
 /**
  * The serialize method is called during xml writing.
  *
  * It should use the $writer argument to encode this object into XML.
  *
  * Important note: it is not needed to create the parent element. The
  * parent element is already created, and we only have to worry about
  * attributes, child elements and text (if any).
  *
  * Important note 2: If you are writing any new elements, you are also
  * responsible for closing them.
  *
  * @param XML\Writer $writer
  * @return void
  */
 public function serializeXml(XML\Writer $writer)
 {
     $writer->write($this->value);
 }
예제 #30
0
 /**
  * @param array $fields
  * @param Writer $writer
  */
 private function writeSubFields(array $fields, Writer $writer)
 {
     array_map(function (SubField $field) use($writer) {
         $writer->write(['name' => static::nameElement('subfield'), 'value' => $field->getContent(), 'attributes' => ['code' => $field->getCode()]]);
     }, $fields);
 }