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


PHP Response::setPublic方法代码示例

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


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

示例1: render

 /**
  * TODO: добавить кеширование вывода
  * 
  * @param FrontendPage $frontPage
  * @return \Illuminate\View\View|null
  * @throws LayoutNotFoundException
  */
 protected function render(FrontendPage $frontPage)
 {
     event('frontend.found', [$frontPage]);
     app()->singleton('frontpage', function () use($frontPage) {
         return $frontPage;
     });
     $layout = $frontPage->getLayoutView();
     if (is_null($layout)) {
         throw new LayoutNotFoundException();
     }
     $widgetCollection = new PageWidgetCollection($frontPage);
     $html = (string) $frontPage->getLayoutView();
     if (auth()->check() and auth()->user()->hasRole(['administrator', 'developer'])) {
         $injectHTML = (string) view('cms::app.partials.toolbar');
         // Insert system HTML before closed tag body
         $matches = preg_split('/(<\\/body>)/i', $html, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
         if (count($matches) > 1) {
             /* assemble the HTML output back with the iframe code in it */
             $html = $matches[0] . $injectHTML . $matches[1] . $matches[2];
         }
     }
     $response = new Response();
     $response->header('Content-Type', $frontPage->getMime());
     if (config('cms.show_response_sign', TRUE)) {
         $response->header('X-Powered-CMS', \CMS::NAME . '/' . \CMS::VERSION);
     }
     $response->setContent($html);
     // Set the ETag header
     $response->setEtag(sha1($html));
     $response->setLastModified($frontPage->getCreatedAt());
     // mark the response as either public or private
     $response->setPublic();
     // Check that the Response is not modified for the given Request
     if ($response->isNotModified($this->request)) {
         // return the 304 Response immediately
         return $response;
     }
     return $response;
 }
开发者ID:BlueCatTAT,项目名称:kodicms-laravel,代码行数:46,代码来源:FrontendController.php

示例2: render

 /**
  * @param View   $layout
  * @param string $mime
  *
  * @return \Illuminate\View\View|null
  * @throws LayoutNotFoundException
  */
 protected function render(View $layout = null, $mime = 'text\\html')
 {
     if (is_null($layout)) {
         throw new LayoutNotFoundException(trans('pages::core.messages.layout_not_set'));
     }
     $html = $layout->render();
     $response = new Response();
     $response->header('Content-Type', $mime);
     if (config('cms.show_response_sign', true)) {
         $response->header('X-Powered-CMS', CMS::getFullName());
     }
     $response->setContent($html);
     // Set the ETag header
     $response->setEtag(md5($html));
     // mark the response as either public or private
     $response->setPublic();
     // Check that the Response is not modified for the given Request
     if ($response->isNotModified($this->request)) {
         // return the 304 Response immediately
         return $response;
     }
     return $response;
 }
开发者ID:KodiComponents,项目名称:module-pages,代码行数:30,代码来源:FrontPageController.php

示例3: getDisplayAttachment

 /**
  * Display an attachment file such as image
  *
  * @param Project    $project
  * @param Issue      $issue
  * @param Attachment $attachment
  * @param Request    $request
  *
  * @return Response
  */
 public function getDisplayAttachment(Project $project, Issue $issue, Attachment $attachment, Request $request)
 {
     $issue->setRelation('project', $project);
     $attachment->setRelation('issue', $issue);
     $path = config('tinyissue.uploads_dir') . '/' . $issue->project_id . '/' . $attachment->upload_token . '/' . $attachment->filename;
     $storage = \Storage::disk('local');
     $length = $storage->size($path);
     $time = $storage->lastModified($path);
     $type = $storage->getDriver()->getMimetype($path);
     $response = new Response();
     $response->setEtag(md5($time . $path));
     $response->setExpires(new \DateTime('@' . ($time + 60)));
     $response->setLastModified(new \DateTime('@' . $time));
     $response->setPublic();
     $response->setStatusCode(200);
     $response->header('Content-Type', $type);
     $response->header('Content-Length', $length);
     $response->header('Content-Disposition', 'inline; filename="' . $attachment->filename . '"');
     $response->header('Cache-Control', 'must-revalidate');
     if ($response->isNotModified($request)) {
         // Return empty response if not modified
         return $response;
     }
     // Return file if first request / modified
     $response->setContent($storage->get($path));
     return $response;
 }
开发者ID:oliverpool,项目名称:tinyissue,代码行数:37,代码来源:IssueController.php


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