PluginProbe ʕ •ᴥ•ʔ
Transferito: WP Migration / trunk
Transferito: WP Migration vtrunk
trunk 11.4.0 12.0.0 13.1.0 14.0.0 14.0.11 14.0.7 14.1.0 14.1.1 14.1.2 14.1.3 14.1.4
transferito / vendor / aws / aws-sdk-php / src / Api / Serializer / QuerySerializer.php
transferito / vendor / aws / aws-sdk-php / src / Api / Serializer Last commit date
Ec2ParamBuilder.php 11 months ago JsonBody.php 11 months ago JsonRpcSerializer.php 11 months ago QueryParamBuilder.php 11 months ago QuerySerializer.php 11 months ago RestJsonSerializer.php 11 months ago RestSerializer.php 11 months ago RestXmlSerializer.php 11 months ago XmlBody.php 11 months ago
QuerySerializer.php
82 lines
1 <?php
2 namespace Aws\Api\Serializer;
3
4 use Aws\Api\Service;
5 use Aws\CommandInterface;
6 use Aws\EndpointV2\EndpointProviderV2;
7 use Aws\EndpointV2\EndpointV2SerializerTrait;
8 use Aws\EndpointV2\Ruleset\RulesetEndpoint;
9 use GuzzleHttp\Psr7\Request;
10 use Psr\Http\Message\RequestInterface;
11
12 /**
13 * Serializes a query protocol request.
14 * @internal
15 */
16 class QuerySerializer
17 {
18 use EndpointV2SerializerTrait;
19
20 private $endpoint;
21 private $api;
22 private $paramBuilder;
23
24 public function __construct(
25 Service $api,
26 $endpoint,
27 callable $paramBuilder = null
28 ) {
29 $this->api = $api;
30 $this->endpoint = $endpoint;
31 $this->paramBuilder = $paramBuilder ?: new QueryParamBuilder();
32 }
33
34 /**
35 * When invoked with an AWS command, returns a serialization array
36 * containing "method", "uri", "headers", and "body" key value pairs.
37 *
38 * @param CommandInterface $command Command to serialize into a request.
39 * @param $endpointProvider Provider used for dynamic endpoint resolution.
40 * @param $clientArgs Client arguments used for dynamic endpoint resolution.
41 *
42 * @return RequestInterface
43 */
44 public function __invoke(
45 CommandInterface $command,
46 $endpoint = null
47 )
48 {
49 $operation = $this->api->getOperation($command->getName());
50 $body = [
51 'Action' => $command->getName(),
52 'Version' => $this->api->getMetadata('apiVersion')
53 ];
54 $commandArgs = $command->toArray();
55
56 // Only build up the parameters when there are parameters to build
57 if ($commandArgs) {
58 $body += call_user_func(
59 $this->paramBuilder,
60 $operation->getInput(),
61 $commandArgs
62 );
63 }
64 $body = http_build_query($body, '', '&', PHP_QUERY_RFC3986);
65 $headers = [
66 'Content-Length' => strlen($body),
67 'Content-Type' => 'application/x-www-form-urlencoded'
68 ];
69
70 if ($endpoint instanceof RulesetEndpoint) {
71 $this->setEndpointV2RequestOptions($endpoint, $headers);
72 }
73
74 return new Request(
75 'POST',
76 $this->endpoint,
77 $headers,
78 $body
79 );
80 }
81 }
82