class XmlEncoder in Zircon Profile 8.0
Same name in this branch
- 8.0 vendor/symfony/serializer/Encoder/XmlEncoder.php \Symfony\Component\Serializer\Encoder\XmlEncoder
- 8.0 core/modules/serialization/src/Encoder/XmlEncoder.php \Drupal\serialization\Encoder\XmlEncoder
Same name and namespace in other branches
- 8 core/modules/serialization/src/Encoder/XmlEncoder.php \Drupal\serialization\Encoder\XmlEncoder
Adds XML support for serializer.
This acts as a wrapper class for Symfony's XmlEncoder so that it is not implementing NormalizationAwareInterface, and can be normalized externally.
Hierarchy
- class \Drupal\serialization\Encoder\XmlEncoder implements DecoderInterface, EncoderInterface
Expanded class hierarchy of XmlEncoder
1 file declares its use of XmlEncoder
- XmlEncoderTest.php in core/
modules/ serialization/ tests/ src/ Unit/ Encoder/ XmlEncoderTest.php - Contains \Drupal\Tests\serialization\Unit\Encoder\XmlEncoderTest.
1 string reference to 'XmlEncoder'
- serialization.services.yml in core/
modules/ serialization/ serialization.services.yml - core/modules/serialization/serialization.services.yml
1 service uses XmlEncoder
- serializer.encoder.xml in core/
modules/ serialization/ serialization.services.yml - Drupal\serialization\Encoder\XmlEncoder
File
- core/
modules/ serialization/ src/ Encoder/ XmlEncoder.php, line 20 - Contains \Drupal\serialization\Encoder\XmlEncoder.
Namespace
Drupal\serialization\EncoderView source
class XmlEncoder implements EncoderInterface, DecoderInterface {
/**
* The formats that this Encoder supports.
*
* @var array
*/
protected static $format = array(
'xml',
);
/**
* An instance of the Symfony XmlEncoder to perform the actual encoding.
*
* @var \Symfony\Component\Serializer\Encoder\XmlEncoder
*/
protected $baseEncoder;
/**
* Gets the base encoder instance.
*
* @return \Symfony\Component\Serializer\Encoder\XmlEncoder
* The base encoder.
*/
public function getBaseEncoder() {
if (!isset($this->baseEncoder)) {
$this->baseEncoder = new BaseXmlEncoder();
}
return $this->baseEncoder;
}
/**
* Sets the base encoder instance.
*
* @param \Symfony\Component\Serializer\Encoder\XmlEncoder $encoder
*/
public function setBaseEncoder($encoder) {
$this->baseEncoder = $encoder;
}
/**
* {@inheritdoc}
*/
public function encode($data, $format, array $context = array()) {
return $this
->getBaseEncoder()
->encode($data, $format, $context);
}
/**
* {@inheritdoc}
*/
public function supportsEncoding($format) {
return in_array($format, static::$format);
}
/**
* {@inheritdoc}
*/
public function decode($data, $format, array $context = array()) {
return $this
->getBaseEncoder()
->decode($data, $format, $context);
}
/**
* {@inheritdoc}
*/
public function supportsDecoding($format) {
return in_array($format, static::$format);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
XmlEncoder:: |
protected | property | An instance of the Symfony XmlEncoder to perform the actual encoding. | |
XmlEncoder:: |
protected static | property | The formats that this Encoder supports. | |
XmlEncoder:: |
public | function |
Decodes a string into PHP data. Overrides DecoderInterface:: |
|
XmlEncoder:: |
public | function |
Encodes data into the given format. Overrides EncoderInterface:: |
|
XmlEncoder:: |
public | function | Gets the base encoder instance. | |
XmlEncoder:: |
public | function | Sets the base encoder instance. | |
XmlEncoder:: |
public | function |
Checks whether the deserializer can decode from given format. Overrides DecoderInterface:: |
|
XmlEncoder:: |
public | function |
Checks whether the serializer can encode to given format. Overrides EncoderInterface:: |