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


PHP Response::setContent方法代码示例

本文整理汇总了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;
 }
开发者ID:niksrc,项目名称:SF,代码行数:35,代码来源:HomepageController.php

示例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);
 }
开发者ID:jraymundoyrockdev,项目名称:api-gfccm-systems,代码行数:15,代码来源:IndexShowCreateUpdateAuth.php

示例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;
 }
开发者ID:wmk223,项目名称:site,代码行数:14,代码来源:Builder.php

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

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

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

示例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);
 }
开发者ID:spatie,项目名称:laravel-cookie-consent,代码行数:12,代码来源:CookieConsentMiddleware.php

示例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);
    }
开发者ID:yajra,项目名称:laravel-disqus,代码行数:41,代码来源:DisqusMiddleware.php

示例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)));
 }
开发者ID:jraymundoyrockdev,项目名称:api-gfccm-systems,代码行数:14,代码来源:IncomeServiceMemberFundsController.php

示例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);
 }
开发者ID:jotaen,项目名称:fractal-response,代码行数:13,代码来源:FractalResponse.php

示例11: responseFactory

 public function responseFactory($content, $code = 200)
 {
     $response = new Response();
     $response->setContent($content);
     $response->setStatusCode($code);
     return $response;
 }
开发者ID:helpscout,项目名称:specter,代码行数:7,代码来源:IlluminateHttpFactory.php

示例12: setResponse

 /**
  * Preparing Response
  *
  * @return Response
  */
 protected function setResponse()
 {
     $response = new Response();
     $response->setStatusCode($this->content['http_code']);
     $response->setContent($this->content);
     return $response;
 }
开发者ID:Baasify,项目名称:Baasify,代码行数:12,代码来源:MainController.php

示例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;
 }
开发者ID:bebetojefry,项目名称:laravel-5,代码行数:8,代码来源:WelcomeController.php

示例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;
 }
开发者ID:projnoah,项目名称:noah,代码行数:16,代码来源:PjaxMiddleware.php

示例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;
 }
开发者ID:AccessibilityNL,项目名称:User-Testing-Tool,代码行数:14,代码来源:Tool.php


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