| 1 |
<?php |
| 2 |
namespace Aws\Api\Serializer; |
| 3 |
|
| 4 |
use Aws\Api\StructureShape; |
| 5 |
use Aws\Api\Service; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
class RestXmlSerializer extends RestSerializer |
| 11 |
{ |
| 12 |
|
| 13 |
private $xmlBody; |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
public function __construct( |
| 21 |
Service $api, |
| 22 |
$endpoint, |
| 23 |
?XmlBody $xmlBody = null |
| 24 |
) { |
| 25 |
parent::__construct($api, $endpoint); |
| 26 |
$this->xmlBody = $xmlBody ?: new XmlBody($api); |
| 27 |
} |
| 28 |
|
| 29 |
protected function payload(StructureShape $member, array $value, array &$opts) |
| 30 |
{ |
| 31 |
$opts['headers']['Content-Type'] = 'application/xml'; |
| 32 |
$body = $this->getXmlBody($member, $value); |
| 33 |
$opts['headers']['Content-Length'] = (string) strlen($body); |
| 34 |
$opts['body'] = $body; |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
private function getXmlBody(StructureShape $member, array $value) |
| 43 |
{ |
| 44 |
$xmlBody = $this->xmlBody->build($member, $value); |
| 45 |
$xmlBody = str_replace("'", "'", $xmlBody); |
| 46 |
$xmlBody = str_replace('\r', " ", $xmlBody); |
| 47 |
$xmlBody = str_replace('\n', " ", $xmlBody); |
| 48 |
return $xmlBody; |
| 49 |
} |
| 50 |
} |