當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。