本文整理匯總了PHP中Buzz\Message\Response::isOk方法的典型用法代碼示例。如果您正苦於以下問題:PHP Response::isOk方法的具體用法?PHP Response::isOk怎麽用?PHP Response::isOk使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Buzz\Message\Response
的用法示例。
在下文中一共展示了Response::isOk方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createFromResponse
/**
* @param Response $response
* @return ProxyMediaInterface
*
* @throws MediaStorageClientManagerNotFoundException
* @throws MediaStorageClientProxyMediaManagerException
*/
public function createFromResponse(Response $response)
{
if ($response && $response->isOk()) {
$content = json_decode($response->getContent(), true);
if ($content && !json_last_error() && is_array($content)) {
$content = new ArrayCollection($content);
} else {
throw new MediaStorageClientProxyMediaManagerException('Client not response new value');
}
} elseif ($response->getStatusCode() == 404) {
throw new MediaStorageClientManagerNotFoundException(sprintf('Unable to find the object'));
} else {
throw new MediaStorageClientProxyMediaManagerException('Client response code: ' . $response->getStatusCode());
}
$proxyMedia = $this->create();
$proxyMedia->setReferenceFull($content->get('reference_full'));
$proxyMedia->setName($content->get('name'));
$proxyMedia->setProviderMetadata($content->toArray());
return $proxyMedia;
}