1: <?php
2:
3: namespace Guzzle\Service\Command\LocationVisitor\Request;
4:
5: use Guzzle\Common\Exception\InvalidArgumentException;
6: use Guzzle\Http\Message\RequestInterface;
7: use Guzzle\Service\Command\CommandInterface;
8: use Guzzle\Service\Description\Parameter;
9:
10: 11: 12:
13: class extends AbstractRequestVisitor
14: {
15: 16: 17:
18: public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, $value)
19: {
20: $value = $param->filter($value);
21: if ($param->getType() == 'object' && $param->getAdditionalProperties() instanceof Parameter) {
22: $this->addPrefixedHeaders($request, $param, $value);
23: } else {
24: $request->setHeader($param->getWireName(), $value);
25: }
26: }
27:
28: 29: 30: 31: 32: 33: 34: 35: 36:
37: protected function (RequestInterface $request, Parameter $param, $value)
38: {
39: if (!is_array($value)) {
40: throw new InvalidArgumentException('An array of mapped headers expected, but received a single value');
41: }
42: $prefix = $param->getSentAs();
43: foreach ($value as $headerName => $headerValue) {
44: $request->setHeader($prefix . $headerName, $headerValue);
45: }
46: }
47: }
48: