PluginProbe
Media Cloud Sync / 1.4.1
Media Cloud Sync v1.4.1
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 1.2.9 All 35 releases
media-cloud-sync / includes / sdk / s3 / Aws / Api / Serializer / RestXmlSerializer.php

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

45 lines 1.4 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 $body = $this->getXmlBody($member, $value);
28 $opts['headers']['Content-Length'] = \strlen($body);
29 $opts['body'] = $body;
30 }
31 /**
32 * @param StructureShape $member
33 * @param array $value
34 * @return string
35 */
36 private function getXmlBody(StructureShape $member, array $value)
37 {
38 $xmlBody = (string) $this->xmlBody->build($member, $value);
39 $xmlBody = \str_replace("'", "&apos;", $xmlBody);
40 $xmlBody = \str_replace('\\r', "&#13;", $xmlBody);
41 $xmlBody = \str_replace('\\n', "&#10;", $xmlBody);
42 return $xmlBody;
43 }
44 }
45