本文整理汇总了PHP中Illuminate\Http\Response::setContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::setContent方法的具体用法?PHP Response::setContent怎么用?PHP Response::setContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Http\Response
的用法示例。
在下文中一共展示了Response::setContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveUser
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function saveUser(Response $response, Request $request)
{
$despo = new Valentine();
$Userexists = Valentine::getExistingUser($request->input('id'));
if (is_object($Userexists)) {
if (!is_null($Userexists->interests)) {
$response->setContent('/findlove');
$response->withCookie(cookie()->forever('shy_first_college', $Userexists->college));
} else {
$response->setContent('/profile/complete');
}
$response->withCookie(cookie()->forever('shy_first_id', $Userexists->id));
$response->withCookie(cookie()->forever('shy_first_sex', $Userexists->sex));
} else {
$despo->name = $request->input('name');
$despo->age = $request->input('birthday', '');
$despo->sex = $request->input('gender');
$despo->userId = $request->input('id');
$despo->tel = $request->input('name');
$despo->social = $request->input('social');
$despo->url = $request->input('link');
$despo->email = $request->input('email');
if ($despo->save()) {
$response->setContent('/profile/complete');
$response->withCookie(cookie()->forever('shy_first_id', $despo->id));
$response->withCookie(cookie()->forever('shy_first_sex', $request->input('sex')));
}
}
return $response;
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$currentUserRoles = $this->grantedRoles();
if (!$this->isAuthorized($currentUserRoles)) {
return $this->response->setContent('Unauthorized')->setStatusCode(401);
}
return $next($request);
}
示例3: render
/**
* Render the feed.
*
* @return \Illuminate\Http\Response
*/
public function render($type)
{
$this->setType($type);
$data = $this->getFeedData();
$view = $this->prepareView($data);
$this->prepareHeaders();
$this->response->setContent($view);
return $this->response;
}
示例4: 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);
}
示例5: 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;
}
示例6: store
/**
* Create new Income Service
*
* @param IncomeServiceRequest $request
* @param Guard $guard
* @param Response $response
* @param Gate $gate
* @return ItemResponse|\Symfony\Component\HttpFoundation\Response
*/
public function store(IncomeServiceRequest $request, Guard $guard, Response $response, Gate $gate)
{
if (!$gate->check('putPostDelete', new IncomeService())) {
return $response->setContent('Unauthorized')->setStatusCode(401);
}
return new ItemResponse($this->dispatch(new CreateIncomeServiceCommand($request->get('service_id'), $request->get('service_date'), $guard->user()->id, 3, 'status')));
}
示例7: 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);
}
示例8: 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);
}
示例9: deleteMemberFund
/**
* Deletes members funds and recalculates total
*
* @param $incomeServiceId
* @param $memberId
* @return \Illuminate\Http\JsonResponse
*/
public function deleteMemberFund($incomeServiceId, $memberId, Response $response, Gate $gate)
{
if (!$gate->check('putPostDelete', new IncomeServiceMemberFund())) {
return $response->setContent('Unauthorized')->setStatusCode(401);
}
return response()->json($this->dispatch(new DeleteIncomeServiceMemberFundTotal($incomeServiceId, $memberId)));
}
示例10: serialize
/**
* Serializes the original content
*
* @param Fractal\ResourceAbstract $resource
* @return $this
*/
protected function serialize($resource)
{
$manager = new Fractal\Manager();
$data = $manager->createData($resource)->toArray()['data'];
$serialized = json_encode($data);
return parent::setContent($serialized);
}
示例11: responseFactory
public function responseFactory($content, $code = 200)
{
$response = new Response();
$response->setContent($content);
$response->setStatusCode($code);
return $response;
}
示例12: setResponse
/**
* Preparing Response
*
* @return Response
*/
protected function setResponse()
{
$response = new Response();
$response->setStatusCode($this->content['http_code']);
$response->setContent($this->content);
return $response;
}
示例13: create
public function create(Request $request)
{
$val = Url::saveUrl($request);
$path = route('short_url', array('short' => $val->getAttribute('short')));
$resp = new Response();
$resp->setContent($path);
return $resp;
}
示例14: 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;
}
示例15: getButton
/**
* Get HTML of the tool button
*
* @return Response The content
*/
public static function getButton()
{
$response = new Response();
$url = route('tool.button.script', ['locale' => Lang::getLocale()]);
$content = '<script src="' . $url . '"></script>' . "\n";
$content .= '<div id="' . static::getId() . '_button"></div>';
$response->setContent($content);
return $response;
}