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


PHP Response::setClientTtl方法代碼示例

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


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

示例1: indexAction

 public function indexAction()
 {
     $response = new Response($this->dumper->dump(), 200, array('Content-Type' => 'application/xml'));
     $response->setPublic();
     $response->setClientTtl($this->httpCache['ttl']);
     return $response;
 }
開發者ID:silvestra,項目名稱:silvestra,代碼行數:7,代碼來源:SitemapController.php

示例2: onKernelRequest

 /**
  * Return the response to the context hash request with a header containing
  * the generated hash.
  *
  * If the ttl is bigger than 0, cache headers will be set for this response.
  *
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($event->getRequestType() != HttpKernelInterface::MASTER_REQUEST) {
         return;
     }
     if (!$this->requestMatcher->matches($event->getRequest())) {
         return;
     }
     $hash = $this->hashGenerator->generateHash();
     // status needs to be 200 as otherwise varnish will not cache the response.
     $response = new Response('', 200, array($this->hashHeader => $hash, 'Content-Type' => 'application/vnd.fos.user-context-hash'));
     if ($this->ttl > 0) {
         $response->setClientTtl($this->ttl);
         $response->setVary($this->userIdentifierHeaders);
         $response->setPublic();
     } else {
         $response->setClientTtl(0);
         $response->headers->addCacheControlDirective('no-cache');
     }
     $event->setResponse($response);
 }
開發者ID:benr77,項目名稱:FOSHttpCacheBundle,代碼行數:29,代碼來源:UserContextSubscriber.php

示例3: testSetClientTtl

 public function testSetClientTtl()
 {
     $response = new Response();
     $response->setClientTtl(10);
     $this->assertEquals($response->getMaxAge(), $response->getAge() + 10);
 }
開發者ID:BozzaCoon,項目名稱:SPHERE-Framework,代碼行數:6,代碼來源:ResponseTest.php

示例4: rssAction

 public function rssAction($uri = null)
 {
     if (null === $this->application) {
         throw new FrontControllerException('A valid BackBee application is required.', FrontControllerException::INTERNAL_ERROR);
     }
     if (false === $this->application->getContainer()->has('site')) {
         throw new FrontControllerException('A BackBee\\Site instance is required.', FrontControllerException::INTERNAL_ERROR);
     }
     $site = $this->application->getContainer()->get('site');
     if (false !== ($ext = strrpos($uri, '.'))) {
         $uri = substr($uri, 0, $ext);
     }
     if ('_root_' == $uri) {
         $page = $this->application->getEntityManager()->getRepository('BackBee\\NestedNode\\Page')->getRoot($site);
     } else {
         $page = $this->application->getEntityManager()->getRepository('BackBee\\NestedNode\\Page')->findOneBy(array('_site' => $site, '_url' => '/' . $uri, '_state' => Page::getUndeletedStates()));
     }
     try {
         $this->application->info(sprintf('Handling URL request `rss%s`.', $uri));
         $response = new Response($this->application->getRenderer()->render($page, 'rss', null, 'rss.phtml', false));
         $response->headers->set('Content-Type', 'text/xml');
         $response->setClientTtl(15);
         $response->setTtl(15);
         $this->send($response);
     } catch (\Exception $e) {
         $this->defaultAction('/rss/' . $uri);
     }
 }
開發者ID:gobjila,項目名稱:BackBee,代碼行數:28,代碼來源:FrontController.php


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