當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Http::setNoCacheHeaders方法代碼示例

本文整理匯總了PHP中Magento\Framework\App\Response\Http::setNoCacheHeaders方法的典型用法代碼示例。如果您正苦於以下問題:PHP Http::setNoCacheHeaders方法的具體用法?PHP Http::setNoCacheHeaders怎麽用?PHP Http::setNoCacheHeaders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\App\Response\Http的用法示例。


在下文中一共展示了Http::setNoCacheHeaders方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: dispatch

 /**
  * Perform action and generate response
  *
  * @param RequestInterface $request
  * @return ResponseInterface|\Magento\Framework\Controller\ResultInterface
  * @throws \LogicException
  */
 public function dispatch(RequestInterface $request)
 {
     \Magento\Framework\Profiler::start('routers_match');
     $routingCycleCounter = 0;
     $result = null;
     while (!$request->isDispatched() && $routingCycleCounter++ < 100) {
         /** @var \Magento\Framework\App\RouterInterface $router */
         foreach ($this->_routerList as $router) {
             try {
                 $actionInstance = $router->match($request);
                 if ($actionInstance) {
                     $request->setDispatched(true);
                     $this->response->setNoCacheHeaders();
                     if ($actionInstance instanceof \Magento\Framework\App\Action\AbstractAction) {
                         $result = $actionInstance->dispatch($request);
                     } else {
                         $result = $actionInstance->execute();
                     }
                     break;
                 }
             } catch (\Magento\Framework\Exception\NotFoundException $e) {
                 $request->initForward();
                 $request->setActionName('noroute');
                 $request->setDispatched(false);
                 break;
             }
         }
     }
     \Magento\Framework\Profiler::stop('routers_match');
     if ($routingCycleCounter > 100) {
         throw new \LogicException('Front controller reached 100 router match iterations');
     }
     return $result;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:41,代碼來源:FrontController.php

示例2: setNoCacheHeaders

 /**
  * {@inheritdoc}
  */
 public function setNoCacheHeaders()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'setNoCacheHeaders');
     if (!$pluginInfo) {
         return parent::setNoCacheHeaders();
     } else {
         return $this->___callPlugins('setNoCacheHeaders', func_get_args(), $pluginInfo);
     }
 }
開發者ID:HaonanXu,項目名稱:der-snack-backup,代碼行數:12,代碼來源:Interceptor.php

示例3: testSetNoCacheHeaders

 /**
  * Test setting public cache headers
  */
 public function testSetNoCacheHeaders()
 {
     $timestamp = 1000000;
     $pragma = 'no-cache';
     $cacheControl = 'max-age=0, must-revalidate, no-cache, no-store';
     $expiresResult = 'Thu, 01 Jan 1970 00:00:00 GMT';
     $this->dateTimeMock->expects($this->once())->method('strToTime')->with('-1 year')->willReturn($timestamp);
     $this->dateTimeMock->expects($this->once())->method('gmDate')->with(Http::EXPIRATION_TIMESTAMP_FORMAT, $timestamp)->willReturn($expiresResult);
     $this->model->setNoCacheHeaders();
     $this->assertEquals($pragma, $this->model->getHeader('Pragma')->getFieldValue());
     $this->assertEquals($cacheControl, $this->model->getHeader('Cache-Control')->getFieldValue());
     $this->assertEquals($expiresResult, $this->model->getHeader('Expires')->getFieldValue());
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:16,代碼來源:HttpTest.php


注:本文中的Magento\Framework\App\Response\Http::setNoCacheHeaders方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。