本文整理汇总了PHP中Sabre\Xml\Writer类的典型用法代码示例。如果您正苦于以下问题:PHP Writer类的具体用法?PHP Writer怎么用?PHP Writer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Writer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmlSerializeValue
/**
* This method serializes only the value of a property. This is used to
* create xCard or xCal documents.
*
* @param Xml\Writer $writer XML writer.
*
* @return void
*/
protected function xmlSerializeValue(Xml\Writer $writer)
{
// xCard is the only XML and JSON format that has the same date and time
// format than vCard.
$valueType = strtolower($this->getValueType());
$writer->writeElement($valueType, $this->getValue());
}
示例2: 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)
{
$collations = ['i;ascii-casemap', 'i;octet', 'i;unicode-casemap'];
foreach ($collations as $collation) {
$writer->writeElement('{' . Plugin::NS_CALDAV . '}supported-collation', $collation);
}
}
示例3: 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();
}
示例4: 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']);
}
示例5: 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]]);
}
示例6: 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->getValue() as $val) {
$writer->startElement('{DAV:}supported-method');
$writer->writeAttribute('name', $val);
$writer->endElement();
}
}
示例7: 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->components as $component) {
$writer->startElement('{' . Plugin::NS_CALDAV . '}comp');
$writer->writeAttributes(['name' => $component]);
$writer->endElement();
}
}
示例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}]);
}
}
}
示例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)
{
foreach ($this->privileges as $privName) {
$writer->startElement('{DAV:}privilege');
$writer->writeElement($privName);
$writer->endElement();
}
}
示例10: xmlSerialize
/**
* 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)
{
foreach ($this->getResponses() as $response) {
$writer->writeElement('{DAV:}response', $response);
}
if ($syncToken = $this->getSyncToken()) {
$writer->writeElement('{DAV:}sync-token', $syncToken);
}
}
示例11: 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->supportedData as $supported) {
$writer->startElement('{' . Plugin::NS_CARDDAV . '}address-data-type');
$writer->writeAttributes(['content-type' => $supported['contentType'], 'version' => $supported['version']]);
$writer->endElement();
// address-data-type
}
}
示例12: 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)
{
if ($this->canBeShared) {
$writer->writeElement('{' . Plugin::NS_CALENDARSERVER . '}can-be-shared');
}
if ($this->canBePublished) {
$writer->writeElement('{' . Plugin::NS_CALENDARSERVER . '}can-be-published');
}
}
示例13: 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();
}
示例14: 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)
{
switch ($this->value) {
case self::TRANSPARENT:
$writer->writeElement('{' . Plugin::NS_CALDAV . '}transparent');
break;
case self::OPAQUE:
$writer->writeElement('{' . Plugin::NS_CALDAV . '}opaque');
break;
}
}
示例15: 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]]);
}
}
}