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


PHP Response::getContent方法代码示例

本文整理汇总了PHP中Illuminate\Http\Response::getContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::getContent方法的具体用法?PHP Response::getContent怎么用?PHP Response::getContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Http\Response的用法示例。


在下文中一共展示了Response::getContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: put

 public function put(Route $route, Request $request, Response $response)
 {
     $key = $this->makeCacheKey($request->url());
     var_dump($response->getContent());
     if (!Cache::has($key)) {
         Cache::put($key, $response->getContent(), 1440);
     }
 }
开发者ID:seivad,项目名称:nnt,代码行数:8,代码来源:CacheFilter.php

示例2: filterResponse

 /**
  * Prepare the PJAX-specific response content.
  *
  * @param Response $response
  * @param string   $container
  *
  * @return $this
  */
 protected function filterResponse(Response $response, $container)
 {
     if (!$response->isSuccessful()) {
         $crawler = new Crawler($response->getContent());
         $response->setContent($this->fetchContents($crawler, '.exception_message'));
         return $this;
     }
     $crawler = new Crawler($response->getContent());
     $response->setContent($this->makeTitle($crawler) . $this->fetchContents($crawler, $container));
     return $this;
 }
开发者ID:shfeat,项目名称:laravel-admin,代码行数:19,代码来源:PjaxMiddleware.php

示例3: addCookieConsentScriptToResponse

 /**
  * @param \Illuminate\Http\Response $response
  *
  * @return $this
  */
 protected function addCookieConsentScriptToResponse(Response $response)
 {
     $content = $response->getContent();
     $closingBodyTagPosition = $this->getLastClosingBodyTagPosition($content);
     $content = '' . substr($content, 0, $closingBodyTagPosition) . view('cookieConsent::index')->render() . substr($content, $closingBodyTagPosition);
     return $response->setContent($content);
 }
开发者ID:spatie,项目名称:laravel-cookie-consent,代码行数:12,代码来源:CookieConsentMiddleware.php

示例4: appendDisqusScript

    /**
     * Append disqus script on the end of the page.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Illuminate\Http\Response $response
     * @return mixed
     */
    protected function appendDisqusScript($request, $response)
    {
        $content = $response->getContent();
        if (!Str::contains($content, '<div id="disqus_thread"></div>')) {
            return;
        }
        $uri = $request->getRequestUri();
        $pageUrl = url($uri);
        $pageId = 'route' . implode('.', explode('/', $uri));
        $username = config('disqus.username');
        $disqusHtml = <<<CDATA
<script>
     var disqus_config = function () {
         this.page.url = '{$pageUrl}';
         this.page.identifier = '{$pageId}';
     };

    (function() {  // DON'T EDIT BELOW THIS LINE
        var d = document, s = d.createElement('script');

        s.src = '//{$username}.disqus.com/embed.js';

        s.setAttribute('data-timestamp', +new Date());
        (d.head || d.body).appendChild(s);
    })();
</script>
<noscript>Please enable JavaScript to view the <a href=\\"https://disqus.com/?ref_noscript\\" rel=\\"nofollow\\">comments powered by Disqus.</a></noscript>
CDATA;
        $bodyPosition = strripos($content, '</body>');
        if (false !== $bodyPosition) {
            $content = substr($content, 0, $bodyPosition) . $disqusHtml . substr($content, $bodyPosition);
        }
        $response->setContent($content);
    }
开发者ID:yajra,项目名称:laravel-disqus,代码行数:41,代码来源:DisqusMiddleware.php

示例5: serialize

 /**
  * Serialize a response.
  *
  * @param \Illuminate\Http\Response $response
  *
  * @return string
  */
 public function serialize(Response $response)
 {
     $content = $response->getContent();
     $statusCode = $response->getStatusCode();
     $headers = $response->headers;
     return serialize(compact('content', 'statusCode', 'headers'));
 }
开发者ID:sdebacker,项目名称:laravel-responsecache,代码行数:14,代码来源:ResponseSerializer.php

示例6: 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

示例7: render

 /**
  * Render an exception into a response.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Exception $exception
  * @return \Illuminate\Http\Response
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function render($request, Exception $exception)
 {
     $response = (new SymfonyExceptionHandler(env('APP_DEBUG', false)))->createResponse($exception);
     $response = new Response($response->getContent(), $response->getStatusCode(), $response->headers->all());
     $response->exception = $exception;
     return $response;
 }
开发者ID:hrslash,项目名称:luminous,代码行数:16,代码来源:Handler.php

示例8: getCrawler

 /**
  * Get the DomCrawler instance.
  *
  * @param \Illuminate\Http\Response $response
  *
  * @return \Symfony\Component\DomCrawler\Crawler
  */
 protected function getCrawler(Response $response)
 {
     if ($this->crawler) {
         return $this->crawler;
     }
     return $this->crawler = new Crawler($response->getContent());
 }
开发者ID:devmatic,项目名称:laravel-instantclick,代码行数:14,代码来源:FilterIfInstantClick.php

示例9: makeRequest

 /**
  * Make a request to the application and create a Crawler instance.
  *
  * @param  string $method
  * @param  string $uri
  * @param  array $parameters
  * @param  array $cookies
  * @param  array $files
  *
  * @return $this
  */
 protected function makeRequest($method, $uri, $parameters = [], $cookies = [], $files = [])
 {
     $uri = $this->prepareUrlForRequest($uri);
     $this->call($method, $uri, $parameters, $cookies, $files);
     $this->clearInputs()->followRedirects()->assertPageLoaded($uri);
     $this->currentUri = $this->app->make('request')->fullUrl();
     $this->crawler = new Crawler($this->response->getContent(), $uri);
     return $this;
 }
开发者ID:sellerlabs,项目名称:illuminated,代码行数:20,代码来源:CrawlerTrait.php

示例10: filterResponse

 /**
  * Prepare the PJAX-specific response content.
  *
  * @param  Response $response
  * @param  string   $container
  * @return $this
  */
 protected function filterResponse(Response $response, $container)
 {
     $crawler = new Crawler($response->getContent());
     $response->setContent($this->makeTitle($crawler) . $this->fetchContents($crawler, $container));
     if ($crawler->filter('script[pjax-script]')->count() > 0) {
         $response->header('X-PJAX-Script', $crawler->filter('script[pjax-script]')->attr('src'));
     }
     return $this;
 }
开发者ID:projnoah,项目名称:noah,代码行数:16,代码来源:PjaxMiddleware.php

示例11: dump

 /**
  * Dump the content from the last response.
  *
  * @return void
  */
 public function dump()
 {
     $content = $this->response->getContent();
     $json = json_decode($content);
     if (json_last_error() === JSON_ERROR_NONE) {
         $content = $json;
     }
     dd($content);
 }
开发者ID:scrubmx,项目名称:framework,代码行数:14,代码来源:MakesHttpRequests.php

示例12: seeJsonContains

 /**
  * Assert that the response contains the given JSON.
  *
  * @param  array  $data
  * @return $this
  */
 protected function seeJsonContains(array $data)
 {
     $actual = json_encode(array_sort_recursive(json_decode($this->response->getContent(), true)));
     foreach (array_sort_recursive($data) as $key => $value) {
         $expected = $this->formatToExpectedJson($key, $value);
         $this->assertTrue(str_contains($actual, $this->formatToExpectedJson($key, $value)), "Unable to find JSON fragment [{$expected}] within [{$actual}].");
     }
     return $this;
 }
开发者ID:alvarobfdev,项目名称:LaravelCore,代码行数:15,代码来源:CrawlerTrait.php

示例13: handleDebugbar

 /**
  * @param \Illuminate\Http\Response $response
  */
 protected function handleDebugbar($response)
 {
     $content = $response->getContent();
     $assets = ['debugbar.css', 'codex-debugbar.css'];
     $out = '';
     foreach ($assets as $style) {
         $out .= '<link type="text/css" rel="stylesheet" href="' . asset('vendor/codex-dev/' . $style) . '"/>';
     }
     $content = str_replace('</body>', $out . '</body>', $content);
     $response->setContent($content);
 }
开发者ID:codexproject,项目名称:core,代码行数:14,代码来源:CodexDev.php

示例14: appendToResponse

 /**
  * Injects the Mail Debug Popup into the Response.
  *
  * @param \Illuminate\Http\Response
  */
 protected function appendToResponse(Response $response)
 {
     $existingContent = $response->getContent();
     $closeBodyPosition = strripos($existingContent, '</body>');
     $appendedContent = "\n            <script>\n                window.open('" . route('mail-debug', ['file' => $this->debug->preview()]) . "','width=680,height=800,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');\n            </script>";
     if ($closeBodyPosition !== false) {
         $response->setContent(substr($existingContent, 0, $closeBodyPosition) . $appendedContent . substr($existingContent, $closeBodyPosition));
         return;
     }
     $response->setContent($existingContent . $appendedContent);
 }
开发者ID:laravelflare,项目名称:mail-debug,代码行数:16,代码来源:MailDebug.php

示例15: fromBaseResponse

 /**
  * Convert the given response into a TestResponse.
  *
  * @param  \Illuminate\Http\Response  $response
  * @return static
  */
 public static function fromBaseResponse($response)
 {
     $testResponse = new static($response->getContent(), $response->status());
     $testResponse->headers = $response->headers;
     if (isset($response->original)) {
         $testResponse->original = $response->original;
     }
     if (isset($response->exception)) {
         $testResponse->exception = $response->exception;
     }
     return $testResponse;
 }
开发者ID:jarnovanleeuwen,项目名称:framework,代码行数:18,代码来源:TestResponse.php


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