PluginProbe
Media Cloud Sync / 1.1.0
Media Cloud Sync v1.1.0
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
media-cloud-sync / includes / sdk / s3 / Aws / Api / Serializer / RestXmlSerializer.php

RestXmlSerializer.php in Media Cloud Sync 1.1.0, at includes/sdk/s3/Aws/Api/Serializer/RestXmlSerializer.php

43 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Dudlewebs\WPMCS\s3\Aws\Api\Serializer;
4
5 use Dudlewebs\WPMCS\s3\Aws\Api\StructureShape;
6 use Dudlewebs\WPMCS\s3\Aws\Api\Service;
7 /**
8 * @internal
9 */
10 class RestXmlSerializer extends RestSerializer
11 {
12 /** @var XmlBody */
13 private $xmlBody;
14 /**
15 * @param Service $api Service API description
16 * @param string $endpoint Endpoint to connect to
17 * @param XmlBody $xmlBody Optional XML formatter to use
18 */
19 public function __construct(Service $api, $endpoint, XmlBody $xmlBody = null)
20 {
21 parent::__construct($api, $endpoint);
22 $this->xmlBody = $xmlBody ?: new XmlBody($api);
23 }
24 protected function payload(StructureShape $member, array $value, array &$opts)
25 {
26 $opts['headers']['Content-Type'] = 'application/xml';
27 $opts['body'] = $this->getXmlBody($member, $value);
28 }
29 /**
30 * @param StructureShape $member
31 * @param array $value
32 * @return string
33 */
34 private function getXmlBody(StructureShape $member, array $value)
35 {
36 $xmlBody = (string) $this->xmlBody->build($member, $value);
37 $xmlBody = \str_replace("'", "&apos;", $xmlBody);
38 $xmlBody = \str_replace('\\r', "&#13;", $xmlBody);
39 $xmlBody = \str_replace('\\n', "&#10;", $xmlBody);
40 return $xmlBody;
41 }
42 }
43