| @@ 5-26 (lines=22) @@ | ||
| 2 | ||
| 3 | namespace Knp\FriendlyContexts\Builder; |
|
| 4 | ||
| 5 | class DeleteRequestBuilder extends AbstractRequestBuilder |
|
| 6 | { |
|
| 7 | public function build($uri = null, array $queries = null, array $headers = null, array $postBody = null, $body = null, array $options = []) |
|
| 8 | { |
|
| 9 | parent::build($uri, $queries, $headers, $postBody, $body, $options); |
|
| 10 | ||
| 11 | if (is_array($body)) { |
|
| 12 | // format the body request to a corect x-www-form-urlencoded |
|
| 13 | $body = $this->formatQueryString($body); |
|
| 14 | // Set a defaut form content type |
|
| 15 | $headers = $headers ?: []; |
|
| 16 | $headers['Content-Type'] = 'application/x-www-form-urlencoded'; |
|
| 17 | } |
|
| 18 | ||
| 19 | $resource = $queries ? |
|
| 20 | sprintf('%s?%s', $uri, $this->formatQueryString($queries)) : |
|
| 21 | $uri |
|
| 22 | ; |
|
| 23 | ||
| 24 | return $this->getClient()->delete($resource, $headers, $body, $options); |
|
| 25 | } |
|
| 26 | } |
|
| 27 | ||
| @@ 5-23 (lines=19) @@ | ||
| 2 | ||
| 3 | namespace Knp\FriendlyContexts\Builder; |
|
| 4 | ||
| 5 | class PatchRequestBuilder extends AbstractRequestBuilder |
|
| 6 | { |
|
| 7 | public function build($uri = null, array $queries = null, array $headers = null, array $postBody = null, $body = null, array $options = []) |
|
| 8 | { |
|
| 9 | parent::build($uri, $queries, $headers, $postBody, $body, $options); |
|
| 10 | ||
| 11 | if (is_array($body)) { |
|
| 12 | // format the body request to a corect x-www-form-urlencoded |
|
| 13 | $body = $this->formatQueryString($body); |
|
| 14 | // Set a defaut form content type |
|
| 15 | $headers = $headers ?: []; |
|
| 16 | $headers['Content-Type'] = 'application/x-www-form-urlencoded'; |
|
| 17 | } |
|
| 18 | ||
| 19 | $resource = $queries ? sprintf('%s?%s', $uri, $this->formatQueryString($queries)) : $uri; |
|
| 20 | ||
| 21 | return $this->getClient()->patch($resource, $headers, $body, $options); |
|
| 22 | } |
|
| 23 | } |
|
| 24 | ||
| @@ 5-23 (lines=19) @@ | ||
| 2 | ||
| 3 | namespace Knp\FriendlyContexts\Builder; |
|
| 4 | ||
| 5 | class PutRequestBuilder extends AbstractRequestBuilder |
|
| 6 | { |
|
| 7 | public function build($uri = null, array $queries = null, array $headers = null, array $postBody = null, $body = null, array $options = []) |
|
| 8 | { |
|
| 9 | parent::build($uri, $queries, $headers, $postBody, $body, $options); |
|
| 10 | ||
| 11 | if (is_array($body)) { |
|
| 12 | // format the body request to a corect x-www-form-urlencoded |
|
| 13 | $body = $this->formatQueryString($body); |
|
| 14 | // Set a defaut form content type |
|
| 15 | $headers = $headers ?: []; |
|
| 16 | $headers['Content-Type'] = 'application/x-www-form-urlencoded'; |
|
| 17 | } |
|
| 18 | ||
| 19 | $resource = $queries ? sprintf('%s?%s', $uri, $this->formatQueryString($queries)) : $uri; |
|
| 20 | ||
| 21 | return $this->getClient()->put($resource, $headers, $body, $options); |
|
| 22 | } |
|
| 23 | } |
|
| 24 | ||