本文整理汇总了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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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'));
}
示例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);
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}