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


PHP Http::setPublicHeaders方法代碼示例

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


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

示例1: aroundDispatch

 /**
  * Call method around dispatch frontend action
  *
  * @param FrontControllerInterface $subject
  * @param \Closure                 $proceed
  * @param RequestInterface         $request
  * @return $this
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  * @SuppressWarnings(PHPMD)
  */
 public function aroundDispatch(FrontControllerInterface $subject, \Closure $proceed, RequestInterface $request)
 {
     $startTime = microtime(true);
     if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
         $startTime = $_SERVER['REQUEST_TIME_FLOAT'];
     }
     /** @var \Magento\Framework\App\Request\Http $request */
     if (strpos($request->getOriginalPathInfo(), 'searchautocomplete/ajax/suggest') !== false) {
         $this->result->init();
         $proceed($request);
         #require for init translations
         $request->setControllerModule('Magento_CatalogSearch');
         $request->setDispatched(true);
         $identifier = 'QUERY_' . $this->storeManager->getStore()->getId() . '_' . md5($request->getParam('q'));
         if ($result = $this->cache->load($identifier)) {
             $result = \Zend_Json::decode($result);
             $result['time'] = round(microtime(true) - $startTime, 4);
             $result['cache'] = true;
             $data = \Zend_Json::encode($result);
         } else {
             // mirasvit core event
             $this->eventManager->dispatch('core_register_urlrewrite');
             $result = $this->result->toArray();
             $result['success'] = true;
             $result['time'] = round(microtime(true) - $startTime, 4);
             $result['cache'] = false;
             $data = \Zend_Json::encode($result);
             $this->cache->save($data, $identifier, [\Magento\PageCache\Model\Cache\Type::CACHE_TAG]);
         }
         $this->response->setPublicHeaders(3600);
         return $this->response->representJson($data);
     } else {
         return $proceed($request);
     }
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:45,代碼來源:Plugin.php

示例2: setPublicHeaders

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

示例3: testSetPublicHeadersWithoutTtl

 /**
  * Test for setting public headers without time to live parameter
  */
 public function testSetPublicHeadersWithoutTtl()
 {
     $this->setExpectedException('InvalidArgumentException', 'Time to live is a mandatory parameter for set public headers');
     $this->model->setPublicHeaders(null);
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:8,代碼來源:HttpTest.php


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