XmlVisitor
extends AbstractRequestVisitor
in package
Location visitor used to serialize XML bodies
Table of Contents
Properties
- $contentType : bool
- $data : SplObjectStorage
Methods
- __construct() : mixed
- after() : mixed
- Called after visiting all parameters
- setContentTypeHeader() : self
- Change the content-type header that is added when XML is found
- visit() : mixed
- Called once for each parameter being visited that matches the location type
- addXml() : mixed
- Recursively build the XML body
- addXmlArray() : mixed
- Add an array to the XML
- addXmlObject() : mixed
- Add an object to the XML
- createRootElement() : XMLWriter
- Create the root XML element to use with a request
- finishDocument() : string
- End the document and return the output
- prepareValue() : array<string|int, mixed>|mixed
- Prepare (filter and set desired name for request item) the value for request.
- resolveRecursively() : array<string|int, mixed>
- Map nested parameters into the location_key based parameters
- startDocument() : XMLWriter
- Create a new xml writer and start a document
- writeAttribute() : mixed
- Write an attribute with namespace if used
- writeElement() : mixed
- Write an element with namespace if used
Properties
$contentType
protected
bool
$contentType
= 'application/xml'
Content-Type header added when XML is found
$data
protected
SplObjectStorage
$data
Data object for persisting XML data
Methods
__construct()
public
__construct() : mixed
after()
Called after visiting all parameters
public
after(CommandInterface $command, RequestInterface $request) : mixed
Parameters
- $command : CommandInterface
-
Command being visited
- $request : RequestInterface
-
Request being visited
setContentTypeHeader()
Change the content-type header that is added when XML is found
public
setContentTypeHeader(string $header) : self
Parameters
- $header : string
-
Header to set when XML is found
Return values
selfvisit()
Called once for each parameter being visited that matches the location type
public
visit(CommandInterface $command, RequestInterface $request, Parameter $param, mixed $value) : mixed
Parameters
- $command : CommandInterface
-
Command being visited
- $request : RequestInterface
-
Request being visited
- $param : Parameter
-
Parameter being visited
- $value : mixed
-
Value to set
addXml()
Recursively build the XML body
protected
addXml(XMLWriter $xmlWriter, Parameter $param, mixed $value) : mixed
Parameters
- $xmlWriter : XMLWriter
-
XML to modify
- $param : Parameter
-
API Parameter
- $value : mixed
-
Value to add
addXmlArray()
Add an array to the XML
protected
addXmlArray(XMLWriter $xmlWriter, Parameter $param, mixed &$value) : mixed
Parameters
- $xmlWriter : XMLWriter
- $param : Parameter
- $value : mixed
addXmlObject()
Add an object to the XML
protected
addXmlObject(XMLWriter $xmlWriter, Parameter $param, mixed &$value) : mixed
Parameters
- $xmlWriter : XMLWriter
- $param : Parameter
- $value : mixed
createRootElement()
Create the root XML element to use with a request
protected
createRootElement(Operation $operation) : XMLWriter
Parameters
- $operation : Operation
-
Operation object
Return values
XMLWriterfinishDocument()
End the document and return the output
protected
finishDocument(XMLWriter $xmlWriter) : string
Parameters
- $xmlWriter : XMLWriter
Return values
string —the writer resource
prepareValue()
Prepare (filter and set desired name for request item) the value for request.
protected
prepareValue(mixed $value, Parameter $param) : array<string|int, mixed>|mixed
Parameters
- $value : mixed
- $param : Parameter
Return values
array<string|int, mixed>|mixedresolveRecursively()
Map nested parameters into the location_key based parameters
protected
resolveRecursively(array<string|int, mixed> $value, Parameter $param) : array<string|int, mixed>
Parameters
- $value : array<string|int, mixed>
-
Value to map
- $param : Parameter
-
Parameter that holds information about the current key
Return values
array<string|int, mixed> —Returns the mapped array
startDocument()
Create a new xml writer and start a document
protected
startDocument(string $encoding) : XMLWriter
Parameters
- $encoding : string
-
document encoding
Return values
XMLWriter —the writer resource
writeAttribute()
Write an attribute with namespace if used
protected
writeAttribute(XMLWriter $xmlWriter, string $prefix, string $name, string $namespace, string $value) : mixed
Parameters
- $xmlWriter : XMLWriter
-
XMLWriter instance
- $prefix : string
-
Namespace prefix if any
- $name : string
-
Attribute name
- $namespace : string
-
The uri of the namespace
- $value : string
-
The attribute content
writeElement()
Write an element with namespace if used
protected
writeElement(XMLWriter $xmlWriter, string $prefix, string $name, string $namespace, string $value) : mixed
Parameters
- $xmlWriter : XMLWriter
-
XML writer resource
- $prefix : string
-
Namespace prefix if any
- $name : string
-
Element name
- $namespace : string
-
The uri of the namespace
- $value : string
-
The element content