当前位置: 首页>>代码示例>>PHP>>正文


PHP Writer::write方法代码示例

本文整理汇总了PHP中Sabre\Xml\Writer::write方法的典型用法代码示例。如果您正苦于以下问题:PHP Writer::write方法的具体用法?PHP Writer::write怎么用?PHP Writer::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sabre\Xml\Writer的用法示例。


在下文中一共展示了Writer::write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generateXML

 /**
  * @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();
 }
开发者ID:mabasic,项目名称:crozilla-integration,代码行数:32,代码来源:Crozilla.php

示例2: buildMessage

 /**
  * @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);
 }
开发者ID:netoholic,项目名称:store-integrator,代码行数:11,代码来源:XMLBuilder.php

示例3: xmlSerialize

    /**
     * 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]]);
            }

        }

    }
开发者ID:nikosv,项目名称:openeclass,代码行数:32,代码来源:PropPatch.php

示例4: xmlSerialize

 /**
  * 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();
         }
     }
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:33,代码来源:PropPatch.php

示例5: testSerialize

    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);
    }
开发者ID:sebbie42,项目名称:casebox,代码行数:25,代码来源:KeyValueTest.php

示例6: xmlSerialize

 /**
  * @param Writer $writer
  * @return void
  */
 function xmlSerialize(Writer $writer)
 {
     // This is required
     $writer->write(['loc' => $this->location]);
     // This is optional
     $this->add($writer, ['lastmod']);
 }
开发者ID:laravelista,项目名称:bard,代码行数:11,代码来源:Sitemap.php

示例7: getXmlFor

 /**
  * 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();
 }
开发者ID:ricardorsierra,项目名称:php-hound,代码行数:12,代码来源:XmlOutput.php

示例8: add

 /**
  * 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}]);
         }
     }
 }
开发者ID:laravelista,项目名称:bard,代码行数:14,代码来源:Common.php

示例9: xmlSerialize

 /**
  * 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]]);
 }
开发者ID:netoholic,项目名称:store-integrator,代码行数:27,代码来源:AmazonProduct.php

示例10: write

 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();
 }
开发者ID:Radiergummi,项目名称:anacronism,代码行数:10,代码来源:XmlTest.php

示例11: __construct

 /**
  * @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();
 }
开发者ID:vircom,项目名称:epuap2,代码行数:25,代码来源:Logout.php

示例12: testSerialize

    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);
    }
开发者ID:sMataruev,项目名称:sabre-xml,代码行数:16,代码来源:CDataTest.php

示例13: testSerialize

    /**
     * @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);
    }
开发者ID:sebbie42,项目名称:casebox,代码行数:21,代码来源:XmlFragmentTest.php

示例14: testSerialize

    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);
    }
开发者ID:sebbie42,项目名称:casebox,代码行数:19,代码来源:UriTest.php

示例15: __construct

 /**
  * @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();
 }
开发者ID:vircom,项目名称:epuap2,代码行数:24,代码来源:Login.php


注:本文中的Sabre\Xml\Writer::write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。