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


PHP sfWebResponse::getDate方法代码示例

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


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

示例1: execute

 public function execute($request)
 {
     $css = Doctrine::getTable('SnsConfig')->get('customizing_css', '');
     $this->getResponse()->setContent($css);
     $this->getResponse()->setContentType('text/css');
     // cache
     $filesystem = new sfFilesystem();
     $dir = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'css';
     @$filesystem->mkdirs($dir);
     file_put_contents($dir . DIRECTORY_SEPARATOR . 'customizing.css', $css);
     $this->getResponse()->setHttpHeader('Last-Modified', sfWebResponse::getDate(time()));
     return sfView::NONE;
 }
开发者ID:newZinc,项目名称:OpenPNE3,代码行数:13,代码来源:customizingCssAction.class.php

示例2: execute

 /**
  * Executes this filter.
  *
  * @param sfFilterChain $filterChain A sfFilterChain instance
  */
 public function execute($filterChain)
 {
     $filterChain->execute();
     $response = $this->getContext()->getResponse();
     $request = $this->getContext()->getRequest();
     if (!headers_sent()) {
         if ($request->getMobile()->isEZweb()) {
             $response->setHttpHeader('Expires', sfWebResponse::getDate(577731600));
             $response->setHttpHeader('LastModified', sfWebResponse::getDate(time()));
             $response->addCacheControlHttpHeader('no-store');
             $response->addCacheControlHttpHeader('no-cache');
             $response->addCacheControlHttpHeader('must-revalidate');
             $response->addCacheControlHttpHeader('post-check', 0);
             $response->addCacheControlHttpHeader('pre-check', 0);
             $response->setHttpHeader('Pragma', 'no-cache');
         }
     }
 }
开发者ID:Kazuhiro-Murota,项目名称:OpenPNE3,代码行数:23,代码来源:opCacheControlFilter.class.php

示例3: execute

 /**
  * Executes this filter.
  *
  * @param sfFilterChain $filterChain A sfFilterChain instance
  */
 public function execute($filterChain)
 {
     $filterChain->execute();
     if (!headers_sent()) {
         $response = $this->getContext()->getResponse();
         if (!$response->hasHttpHeader('Pragma') && !$response->hasHttpHeader('Expires') && !$response->hasHttpHeader('Cache-Control')) {
             $response->setHttpHeader('Expires', sfWebResponse::getDate(577731600));
             $response->setHttpHeader('LastModified', sfWebResponse::getDate(time()));
             $response->addCacheControlHttpHeader('no-store');
             $response->addCacheControlHttpHeader('no-cache');
             $response->addCacheControlHttpHeader('private');
             $response->addCacheControlHttpHeader('max-age', 0);
             $response->addCacheControlHttpHeader('must-revalidate');
             $response->addCacheControlHttpHeader('post-check', 0);
             $response->addCacheControlHttpHeader('pre-check', 0);
             $response->setHttpHeader('Pragma', 'no-cache');
         }
     }
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:24,代码来源:opCacheControlFilter.class.php

示例4: sfTestFunctional

<?php

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
$app = 'cache';
if (!(include dirname(__FILE__) . '/../bootstrap/functional.php')) {
    return;
}
$b = new sfTestFunctional(new sfBrowser());
$b->info('No expiration (client_lifetime is 0)')->get('/httpcache/page1')->with('response')->begin()->isHeader('Last-Modified', '/^' . substr(preg_quote(sfWebResponse::getDate(time()), '/'), 5, 16) . '/')->isHeader('ETag', true)->isHeader('Expires', false)->isHeader('Cache-Control', false)->end();
$b->info('Expiration (client_lifetime is 86400)')->get('/httpcache/page2')->with('response')->begin()->isHeader('Last-Modified', false)->isHeader('ETag', false)->isHeader('Expires', '/^' . substr(preg_quote(sfWebResponse::getDate(time() + 86400), '/'), 5, 16) . '/')->isHeader('Cache-Control', '/max-age=86400/')->end();
$b->info('Expiration (client_lifetime is 86400) but the developer has set a Last-Modified header')->get('/httpcache/page3')->with('response')->begin()->isHeader('Last-Modified', '/^' . substr(preg_quote(sfWebResponse::getDate(time() - 86400), '/'), 5, 16) . '/')->isHeader('ETag', false)->isHeader('Expires', false)->isHeader('Cache-Control', false)->end();
$b->info('No expiration and the developer has set a Last-Modified header')->get('/httpcache/page4')->with('response')->begin()->isHeader('Last-Modified', '/^' . substr(preg_quote(sfWebResponse::getDate(time() - 86400), '/'), 5, 16) . '/')->isHeader('ETag', true)->isHeader('Expires', false)->isHeader('Cache-Control', false)->end();
开发者ID:hunde,项目名称:bsc,代码行数:18,代码来源:httpcacheTest.php

示例5: myTestBrowser

        $content2 = $response->getContent();
        $contentType2 = $response->getContentType();
        $headers2 = $response->getHttpHeaders();
        $b->test()->is($content1, $content2, 'response content is the same');
        $b->test()->is($contentType1, $contentType2, 'response content type is the same');
        $b->test()->is($headers1, $headers2, 'response http headers are the same');
    }
}
$b = new myTestBrowser();
// non HTML cache
$image = file_get_contents(__DIR__ . '/fixtures/apps/cache/modules/cache/data/ok48.png');
sfConfig::set('sf_web_debug', true);
$b->get('/cache/imageWithLayoutCacheWithLayout')->with('view_cache')->isCached(true, true)->checkResponseContent($image, 'image (with layout/page cache) in cache is not decorated when web_debug is on')->get('/cache/imageWithLayoutCacheWithLayout')->with('view_cache')->isCached(true, true)->checkResponseContent($image, 'image (with layout/page cache) in cache is not decorated when web_debug is on')->get('/cache/imageWithLayoutCacheNoLayout')->with('view_cache')->isCached(true)->checkResponseContent($image, 'image (with layout/action cache) in cache is not decorated when web_debug is on')->get('/cache/imageWithLayoutCacheNoLayout')->with('view_cache')->isCached(true)->checkResponseContent($image, 'image (with layout/action cache) in cache is not decorated when web_debug is on')->get('/cache/imageNoLayoutCacheWithLayout')->with('view_cache')->isCached(true, true)->checkResponseContent($image, 'image (no layout/page cache) in cache is not decorated when web_debug is on')->get('/cache/imageNoLayoutCacheWithLayout')->with('view_cache')->isCached(true, true)->checkResponseContent($image, 'image (no layout/page cache) in cache is not decorated when web_debug is on')->get('/cache/imageNoLayoutCacheNoLayout')->with('view_cache')->isCached(true)->checkResponseContent($image, 'image (no layout/action cache) in cache is not decorated when web_debug is on')->get('/cache/imageNoLayoutCacheNoLayout')->with('view_cache')->isCached(true)->checkResponseContent($image, 'image (no layout/action cache) in cache is not decorated when web_debug is on');
sfConfig::set('sf_web_debug', false);
// check stylesheets, javascripts inclusions
sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
$b->get('/cache/multiBis')->with('request')->begin()->isParameter('module', 'cache')->isParameter('action', 'multiBis')->end()->with('response')->begin()->isStatusCode(200)->checkElement('link[href*="/main_css"]')->checkElement('script[src*="/main_js"]')->checkElement('link[href*="/partial_css"]')->checkElement('script[src*="/partial_js"]')->checkElement('link[href*="/another_partial_css"]')->checkElement('script[src*="/another_partial_js"]')->checkElement('link[href*="/component_css"]')->checkElement('script[src*="/component_js"]')->checkElement('#partial_slot_content', 'Partial')->checkElement('#another_partial_slot_content', 'Another Partial')->checkElement('#component_slot_content', 'Component')->end()->get('/cache/multiBis')->with('response')->begin()->checkElement('link[href*="/main_css"]')->checkElement('script[src*="/main_js"]')->checkElement('link[href*="/partial_css"]')->checkElement('script[src*="/partial_js"]')->checkElement('link[href*="/another_partial_css"]')->checkElement('script[src*="/another_partial_js"]')->checkElement('link[href*="/component_css"]')->checkElement('script[src*="/component_js"]')->checkElement('#partial_slot_content', 'Partial')->checkElement('#another_partial_slot_content', 'Another Partial')->checkElement('#component_slot_content', 'Component')->end();
$b->get('/cache/partial')->with('request')->begin()->isParameter('module', 'cache')->isParameter('action', 'partial')->end()->with('response')->begin()->isStatusCode(200)->checkElement('link[href*="/main_css"]', false)->checkElement('script[src*="/main_js"]', false)->checkElement('link[href*="/partial_css"]')->checkElement('script[src*="/partial_js"]')->checkElement('link[href*="/another_partial_css"]')->checkElement('script[src*="/another_partial_js"]')->checkElement('link[href*="/component_css"]', false)->checkElement('script[src*="/component_js"]', false)->checkElement('#partial_slot_content', 'Partial')->checkElement('#another_partial_slot_content', 'Another Partial')->checkElement('#component_slot_content', '')->end()->get('/cache/anotherPartial')->with('request')->begin()->isParameter('module', 'cache')->isParameter('action', 'anotherPartial')->end()->with('response')->begin()->isStatusCode(200)->checkElement('link[href*="/main_css"]', false)->checkElement('script[src*="/main_js"]', false)->checkElement('link[href*="/partial_css"]', false)->checkElement('script[src*="/partial_js"]', false)->checkElement('link[href*="/another_partial_css"]')->checkElement('script[src*="/another_partial_js"]')->checkElement('link[href*="/component_css"]', false)->checkElement('script[src*="/component_js"]', false)->checkElement('#partial_slot_content', '')->checkElement('#another_partial_slot_content', 'Another Partial')->checkElement('#component_slot_content', '')->end()->get('/cache/component')->with('request')->begin()->isParameter('module', 'cache')->isParameter('action', 'component')->end()->with('response')->begin()->isStatusCode(200)->checkElement('link[href*="/main_css"]', false)->checkElement('script[src*="/main_js"]', false)->checkElement('link[href*="/partial_css"]', false)->checkElement('script[src*="/partial_js"]', false)->checkElement('link[href*="/another_partial_css"]', false)->checkElement('script[src*="/another_partial_js"]', false)->checkElement('link[href*="/component_css"]')->checkElement('script[src*="/component_js"]')->checkElement('#partial_slot_content', '')->checkElement('#another_partial_slot_content', '')->checkElement('#component_slot_content', 'Component')->end();
$b->get('/')->with('view_cache')->isUriCached('cache/list', false)->get('/cache/list')->with('view_cache')->isUriCached('cache/list', true)->with('view_cache')->isUriCached('cache/list?page=10', false)->get('/cache/list?page=10')->with('response')->checkElement('#page', '10')->with('view_cache')->isUriCached('cache/list?page=10', true)->with('view_cache')->isUriCached('cache/list?page=20', false)->get('/cache/list?page=20')->with('response')->checkElement('#page', '20')->with('view_cache')->isUriCached('cache/list?page=20', true);
// check for 304 response
sfConfig::set('LAST_MODIFIED', strtotime('2010-01-01'));
$b->get('/cache/lastModifiedResponse')->with('response')->isStatusCode(200);
$b->setHttpHeader('If-Modified-Since', sfWebResponse::getDate(sfConfig::get('LAST_MODIFIED')))->get('/cache/lastModifiedResponse')->with('response')->isStatusCode(304);
// test with sfFileCache class (default)
$b->launch();
// test with sfSQLiteCache class
if (extension_loaded('SQLite') || extension_loaded('pdo_SQLite')) {
    sfConfig::set('sf_factory_view_cache', 'sfSQLiteCache');
    sfConfig::set('sf_factory_view_cache_parameters', array('database' => sfConfig::get('sf_template_cache_dir') . DIRECTORY_SEPARATOR . 'cache.db'));
    $b->launch();
}
开发者ID:Phennim,项目名称:symfony1,代码行数:31,代码来源:cacheTest.php

示例6: executePage4

 public function executePage4(sfWebRequest $request)
 {
     $this->getResponse()->setHttpHeader('Last-Modified', sfWebResponse::getDate(time() - 86400));
     $this->setTemplate('index');
 }
开发者ID:vcgato29,项目名称:poff,代码行数:5,代码来源:actions.class.php

示例7: strtotime

  ->with('view_cache')->isUriCached('cache/list?page=10', true)

  // include different GET parameters
  ->with('view_cache')->isUriCached('cache/list?page=20', false)
  ->get('/cache/list?page=20')
  ->with('response')->checkElement('#page', '20')
  ->with('view_cache')->isUriCached('cache/list?page=20', true)
;

// check for 304 response
sfConfig::set('LAST_MODIFIED', strtotime('2010-01-01'));
$b->get('/cache/lastModifiedResponse')
  ->with('response')->isStatusCode(200)
;

$b->setHttpHeader('If-Modified-Since', sfWebResponse::getDate(sfConfig::get('LAST_MODIFIED')))
  ->get('/cache/lastModifiedResponse')
  ->with('response')->isStatusCode(304)
;

// test with sfFileCache class (default)
$b->launch();

// test with sfSQLiteCache class
if (extension_loaded('SQLite') || extension_loaded('pdo_SQLite'))
{
  sfConfig::set('sf_factory_view_cache', 'sfSQLiteCache');
  sfConfig::set('sf_factory_view_cache_parameters', array('database' => sfConfig::get('sf_template_cache_dir').DIRECTORY_SEPARATOR.'cache.db'));
  $b->launch();
}
开发者ID:nationalfield,项目名称:symfony,代码行数:30,代码来源:cacheTest.php

示例8: get

  get('/httpcache/page2')->
  with('response')->begin()->
    isHeader('Last-Modified', false)->
    isHeader('ETag', false)->
    isHeader('Expires', '/^'.substr(preg_quote(sfWebResponse::getDate(time() + 86400), '/'), 5, 16).'/')->
    isHeader('Cache-Control', '/max-age=86400/')->
  end()
;

$b->
  info('Expiration (client_lifetime is 86400) but the developer has set a Last-Modified header')->
  get('/httpcache/page3')->
  with('response')->begin()->
    isHeader('Last-Modified', '/^'.substr(preg_quote(sfWebResponse::getDate(time() - 86400), '/'), 5, 16).'/')->
    isHeader('ETag', false)->
    isHeader('Expires', false)->
    isHeader('Cache-Control', false)->
  end()
;

$b->
  info('No expiration and the developer has set a Last-Modified header')->
  get('/httpcache/page4')->
  with('response')->begin()->
    isHeader('Last-Modified', '/^'.substr(preg_quote(sfWebResponse::getDate(time() - 86400), '/'), 5, 16).'/')->
    isHeader('ETag', true)->
    isHeader('Expires', false)->
    isHeader('Cache-Control', false)->
  end()
;
开发者ID:nationalfield,项目名称:symfony,代码行数:30,代码来源:httpcacheTest.php


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