本文整理汇总了PHP中sfResponse类的典型用法代码示例。如果您正苦于以下问题:PHP sfResponse类的具体用法?PHP sfResponse怎么用?PHP sfResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sfResponse类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setCacheHeaders
/**
* Send cache headers if possible.
*
* @author Alexandre Mogère
* @param sfResponse $response
* @return void
*/
public static function setCacheHeaders($response)
{
$max_age = sfConfig::get('app_sfJqueryValidationPlugin_client_cache_max_age', false);
if ($max_age !== false) {
$lifetime = $max_age * 86400;
// 24*60*60
$response->addCacheControlHttpHeader('max-age', $lifetime);
$response->setHttpHeader('Pragma', sfConfig::get('app_sfJqueryValidationPlugin_pragma_header', 'public'));
$response->setHttpHeader('Expires', $response->getDate(time() + $lifetime));
}
}
示例2: responseAsArray
/**
* Returns response parameters as an array.
*
* @param sfResponse $response A sfResponse instance
*
* @return array The response parameters
*/
public static function responseAsArray(sfResponse $response = null)
{
if (!$response) {
return array();
}
return array('status' => array('code' => $response->getStatusCode(), 'text' => $response->getStatusText()), 'options' => $response->getOptions(), 'cookies' => method_exists($response, 'getCookies') ? $response->getCookies() : array(), 'httpHeaders' => method_exists($response, 'getHttpHeaders') ? $response->getHttpHeaders() : array(), 'javascripts' => method_exists($response, 'getJavascripts') ? $response->getJavascripts('ALL') : array(), 'stylesheets' => method_exists($response, 'getStylesheets') ? $response->getStylesheets('ALL') : array(), 'metas' => method_exists($response, 'getMetas') ? $response->getMetas() : array(), 'httpMetas' => method_exists($response, 'getHttpMetas') ? $response->getHttpMetas() : array());
}
示例3: array
<?php
// auto-generated by sfFactoryConfigHandler
// date: 2009/08/15 10:45:03
$this->controller = sfController::newInstance(sfConfig::get('sf_factory_controller', 'sfFrontWebController'));
$this->request = sfRequest::newInstance(sfConfig::get('sf_factory_request', 'sfWebRequest'));
$this->response = sfResponse::newInstance(sfConfig::get('sf_factory_response', 'sfWebResponse'));
$this->storage = sfStorage::newInstance(sfConfig::get('sf_factory_storage', 'sfSessionStorage'));
$this->user = sfUser::newInstance(sfConfig::get('sf_factory_user', 'myUser'));
$this->controller->initialize($this);
$this->request->initialize($this, sfConfig::get('sf_factory_request_parameters', NULL), sfConfig::get('sf_factory_request_attributes', array()));
$this->response->initialize($this, sfConfig::get('sf_factory_response_parameters', NULL));
$this->storage->initialize($this, sfConfig::get('sf_factory_storage_parameters', array('session_name' => 'symfony')));
$this->user->initialize($this, sfConfig::get('sf_factory_user_parameters', NULL));
if (sfConfig::get('sf_cache')) {
$this->viewCacheManager = new sfViewCacheManager();
$this->viewCacheManager->initialize($this, sfConfig::get('sf_factory_view_cache', 'sfFileCache'), sfConfig::get('sf_factory_view_cache_parameters', array('automaticCleaningFactor' => 0, 'cacheDir' => '/Users/takizo/Sites/coscupdemo/cache/frontend/dev/template')));
}
示例4: setCacheHeaders
/**
* Send cache headers if possible.
*
* @author Alexandre Mogère
* @param sfResponse $response
*/
public static function setCacheHeaders($response)
{
$max_age = sfConfig::get('app_sfCombinePlusPlugin_client_cache_max_age', false);
if ($max_age !== false) {
$lifetime = $max_age * 86400;
// 24*60*60
$response->addCacheControlHttpHeader('max-age', $lifetime);
$response->setHttpHeader('Pragma', null, false);
$response->setHttpHeader('Expires', null, false);
}
}
示例5: array
$response->addJavascript('first', 'first');
$t->ok($response->getParameterHolder()->has('first', 'helper/asset/auto/javascript/first'), '->addJavascript() takes a position as its second argument');
$response->addJavascript('last', 'last');
$t->ok($response->getParameterHolder()->has('last', 'helper/asset/auto/javascript/last'), '->addJavascript() takes a position as its second argument');
// ->getJavascripts()
$t->diag('->getJavascripts()');
$t->is($response->getJavascripts(), array('test' => 'test', 'foo' => 'foo'), '->getJavascripts() returns all current registered javascripts');
$t->is($response->getJavascripts('first'), array('first' => 'first'), '->getJavascripts() takes a position as its first argument');
$t->is($response->getJavascripts('last'), array('last' => 'last'), '->getJavascripts() takes a position as its first argument');
// ->setCookie() ->getCookies()
$t->diag('->setCookie() ->getCookies()');
$response->setCookie('foo', 'bar');
$t->is($response->getCookies(), array('foo' => array('name' => 'foo', 'value' => 'bar', 'expire' => null, 'path' => '/', 'domain' => '', 'secure' => false, 'httpOnly' => false)), '->setCookie() adds a cookie for the response');
// ->setHeaderOnly() ->getHeaderOnly()
$t->diag('->setHeaderOnly() ->isHeaderOnly()');
$response = sfResponse::newInstance('myWebResponse');
$response->initialize($context);
$t->is($response->isHeaderOnly(), false, '->isHeaderOnly() returns false if the content must be send to the client');
$response->setHeaderOnly(true);
$t->is($response->isHeaderOnly(), true, '->setHeaderOnly() changes the current value of header only');
// ->sendContent()
$t->diag('->sendContent()');
$response->setHeaderOnly(true);
$response->setContent('foo');
ob_start();
$response->sendContent();
$t->is(ob_get_clean(), '', '->sendContent() returns nothing if headerOnly is true');
$response->setHeaderOnly(false);
$response->setContent('foo');
ob_start();
$response->sendContent();
示例6: sendContent
/**
* Send content for the current web response.
*
*/
public function sendContent()
{
if (!$this->headerOnly) {
parent::sendContent();
}
}