本文整理汇总了PHP中GuzzleHttp\ClientInterface::patch方法的典型用法代码示例。如果您正苦于以下问题:PHP ClientInterface::patch方法的具体用法?PHP ClientInterface::patch怎么用?PHP ClientInterface::patch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\ClientInterface
的用法示例。
在下文中一共展示了ClientInterface::patch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Execute an operaction
*
* A successful operation will return result as an array.
* An unsuccessful operation will return null.
*
* @param OperationInterface $op
* @return array|null
*/
public function execute(OperationInterface $op)
{
try {
if ($op instanceof DeleteOperationInterface) {
$response = $this->httpClient->delete($op->getEndpoint(), ['headers' => $op->getHeaders()]);
} elseif ($op instanceof PostOperationInterface) {
$response = $this->httpClient->post($op->getEndpoint(), ['headers' => $op->getHeaders(), 'body' => $op->getData()]);
} elseif ($op instanceof PatchOperationInterface) {
$response = $this->httpClient->patch($op->getEndpoint(), ['headers' => $op->getHeaders(), 'body' => $op->getData()]);
} elseif ($op instanceof PutOperationInterface) {
$response = $this->httpClient->put($op->getEndpoint(), ['headers' => $op->getHeaders(), 'body' => $op->getData()]);
} else {
$response = $this->httpClient->get($op->getEndpoint());
}
} catch (GuzzleHttp\Exception\ClientException $e) {
throw new Exception\ClientException('ClientException occurred in request to Orchestrate: ' . $e->getMessage(), $e->getCode(), $e);
} catch (GuzzleHttp\Exception\ServerException $e) {
throw new Exception\ServerException('ServerException occurred in request to Orchestrate: ' . $e->getMessage(), $e->getCode(), $e);
}
$refLink = null;
$location = null;
if ($response->hasHeader('ETag')) {
$refLink = str_replace('"', '', $response->getHeaderLine('ETag'));
} elseif ($response->hasHeader('Link')) {
$refLink = str_replace(['<', '>; rel="next"'], ['', ''], $response->getHeaderLine('Link'));
}
if ($response->hasHeader('Location')) {
$location = $response->getHeaderLine('Location');
}
$rawValue = $response->getBody(true);
$value = json_decode($rawValue, true);
return $op->getObjectFromResponse($refLink, $location, $value, $rawValue);
}
示例2: patch
/**
* {@inheritDoc}
*/
public function patch(Request $request)
{
$response = null;
try {
$response = $this->client->patch($request->getPath(), array_merge(['body' => $request->getBody()], $this->getConfiguration($request)));
} catch (RequestException $e) {
$this->handleRequestException($request, $e);
}
return $this->createResponse($response);
}
示例3: completeTask
/**
* Completes a task
*
* @param int $task_id
* @param int $revision
* @return mixed
*/
public function completeTask($task_id, $revision)
{
if (!is_numeric($task_id)) {
throw new \InvalidArgumentException('The list id must be numeric.');
} elseif (!is_numeric($revision)) {
throw new \InvalidArgumentException('The revision must be numeric.');
}
$response = $this->client->patch('tasks/' . $task_id, ['body' => json_encode(['revision' => (int) $revision, 'completed' => true])]);
$this->checkResponseStatusCode($response, 200);
return json_decode($response->getBody());
}
示例4: patch
/**
* {@inheritdoc}
*/
public function patch($url = null, array $headers = [], $content = null)
{
try {
// http://guzzle.readthedocs.org/en/latest/clients.html#request-options
$options = array('headers' => $headers, 'body' => $content);
$response = $this->guzzleClient->patch($url, $options);
} catch (\Exception $e) {
throw new RequestException($e->getMessage(), $e->getCode(), $e);
}
return new Response($response->getStatusCode(), $response->getHeaders(), (string) $response->getBody());
}
示例5: patch
/**
* Make a PATCH request.
*
* @param string $url
* @param array $options
* @return object
*/
public function patch($url, array $options = [])
{
$response = $this->client->patch($url, $options);
return $this->getBody($response);
}
示例6: patch
/**
* {@inheritdoc }
*/
public function patch($url, array $body)
{
return $this->httpClient->patch($url, ['body' => $body]);
}