当前位置: 首页>>代码示例>>PHP>>正文


PHP Response::getOriginalContent方法代码示例

本文整理汇总了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);
 }
开发者ID:alfred-nutile-inc,项目名称:incomings-client,代码行数:7,代码来源:IncomingsMiddleWare.php

示例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;
 }
开发者ID:nodes-php,项目名称:api,代码行数:17,代码来源:Response.php

示例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);
         }
     }
 }
开发者ID:BePsvPT,项目名称:CCU,代码行数:25,代码来源:SetCacheHeaders.php

示例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');
     }
 }
开发者ID:xEdelweiss,项目名称:my-perfect-back-end,代码行数:27,代码来源:ResponseAdapter.php

示例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'));
         }
     }
 }
开发者ID:shaggyz,项目名称:sitemap,代码行数:16,代码来源:Sitemap.php

示例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;
 }
开发者ID:JamesGuthrie,项目名称:api,代码行数:13,代码来源:Response.php

示例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()));
 }
开发者ID:bycedric,项目名称:allay,代码行数:10,代码来源:TransformResponseToArray.php

示例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());
 }
开发者ID:iwillhappy1314,项目名称:laravel-admin,代码行数:10,代码来源:Response.php

示例9: printResponseOriginContent

 /**
  * @return $this
  */
 public function printResponseOriginContent()
 {
     print_r((string) $this->response->getOriginalContent());
     return $this;
 }
开发者ID:someline,项目名称:rest-api-client,代码行数:8,代码来源:RestClient.php


注:本文中的Illuminate\Http\Response::getOriginalContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。