本文整理汇总了PHP中Illuminate\Http\Response::getOriginalContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::getOriginalContent方法的具体用法?PHP Response::getOriginalContent怎么用?PHP Response::getOriginalContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Http\Response
的用法示例。
在下文中一共展示了Response::getOriginalContent方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeMessageFromResponse
protected function makeMessageFromResponse(Response $response)
{
$message['original_content'] = $response->getOriginalContent();
$message['content'] = $response->getContent();
$message['status_code'] = $response->getStatusCode();
return json_encode($message, JSON_PRETTY_PRINT);
}
示例2: makeFromExisting
/**
* Make an API response from an existing response object.
*
* @author Morten Rugaard <moru@nodes.dk>
*
* @param \Illuminate\Http\Response $old
* @return \Nodes\Api\Http\Response
*/
public static function makeFromExisting(IlluminateResponse $old)
{
// Support for custom status code and message
$statusCode = $old instanceof self ? $old->getStatusCodeAndMessage() : $old->getStatusCode();
// Generate API response from response object
$new = static::create($old->getOriginalContent(), $statusCode);
$new->headers = $old->headers;
return $new;
}
示例3: setCacheHeaders
/**
* Set cache headers and 304 not modify if needed.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Response $response
*/
protected function setCacheHeaders($request, $response)
{
if (starts_with($request->getPathInfo(), ['/images'])) {
$stat = stat(session()->pull('requestImagePath'));
} else {
if (($view = $response->getOriginalContent()) instanceof View) {
$stat = stat($view->getPath());
}
}
if (isset($stat)) {
$response->setCache(['etag' => md5("{$stat['ino']}|{$stat['mtime']}|{$stat['size']}"), 'public' => true]);
$response->setExpires(Carbon::now()->addDays(30));
if (null !== ($etag = $request->headers->get('If-None-Match')) || null !== $request->headers->get('If-Modified-Since')) {
$etags = explode('-', $etag, -1);
$request->headers->set('If-None-Match', count($etags) ? $etags[0] . '"' : $etag);
$response->isNotModified($request);
}
}
}
示例4: getResultFromResponse
/**
* @param Response $response
* @return mixed
* @throws \Exception
*/
protected function getResultFromResponse(Response $response)
{
$result = $response->getOriginalContent();
switch (true) {
case is_string($result):
/** @var string $result */
return ['type' => 'string', 'data' => $result];
case $result instanceof View:
/** @var View $result */
return ['type' => 'view', 'data' => $result->render()];
case $result instanceof Model:
/** @var Model $result */
return ['type' => strtolower((new \ReflectionClass($result))->getShortName()), 'data' => $result->toArray()];
case $result instanceof Collection:
case is_array($result):
return ['type' => 'collection', 'data' => $result];
case is_null($result):
return ['type' => 'null', 'data' => null];
default:
throw new \Exception('Object of class ' . get_class($response) . ' could not be converted to JSON');
}
}
示例5: saveCachedView
/**
* Save a cached view if caching is enabled.
*
* @param \Illuminate\Http\Response $response
* @return void
*/
protected function saveCachedView(Response $response)
{
if (config('sitemap.cache_enabled')) {
$key = $this->getCacheKey();
$content = $response->getOriginalContent()->render();
if (!$this->cache->get($key)) {
$this->cache->put($key, $content, config('sitemap.cache_length'));
}
}
}
示例6: makeFromExisting
/**
* Make an API response from an existing Illuminate response.
*
* @param \Illuminate\Http\Response $old
*
* @return \Dingo\Api\Http\Response
*/
public static function makeFromExisting(IlluminateResponse $old)
{
$new = static::create($old->getOriginalContent(), $old->getStatusCode());
$new->headers = $old->headers;
return $new;
}
示例7: transformContent
/**
* Replace the content of the response, with the transformed content.
*
* @param \Illuminate\Http\Response $response
* @return void
*/
protected function transformContent(Response $response)
{
$response->setContent($this->transformer->transform($response->getOriginalContent(), $response->getStatusCode()));
}
示例8: makeFromExisting
/**
* Make an API response from an existing Illuminate response.
*
* @param \Illuminate\Http\Response $response
* @return \Dingo\Api\Http\Response
*/
public static function makeFromExisting(IlluminateResponse $response)
{
return new static($response->getOriginalContent(), $response->getStatusCode(), $response->headers->all());
}
示例9: printResponseOriginContent
/**
* @return $this
*/
public function printResponseOriginContent()
{
print_r((string) $this->response->getOriginalContent());
return $this;
}