本文整理汇总了PHP中sfValidatorBase::setCharset方法的典型用法代码示例。如果您正苦于以下问题:PHP sfValidatorBase::setCharset方法的具体用法?PHP sfValidatorBase::setCharset怎么用?PHP sfValidatorBase::setCharset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfValidatorBase
的用法示例。
在下文中一共展示了sfValidatorBase::setCharset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
// ->setMessages()
$t->diag('->setMessages()');
$v->setMessages(array('required' => 'This is required!'));
$t->is($v->getMessages(), array('invalid' => 'Invalid.', 'required' => 'This is required!'), '->setMessages() changes all error messages');
// ->addMessage()
$t->diag('->addMessage()');
$v->addMessage('foobar', 'foo');
$v->setMessage('foobar', 'bar');
$t->is($v->getMessage('foobar'), 'bar', '->addMessage() adds a new error code');
// ->getErrorCodes()
$t->diag('->getErrorCodes()');
$t->is($v->getErrorCodes(), array('required', 'invalid', 'foo'), '->getErrorCodes() returns an array of error codes the validator can use');
// ::getCharset() ::setCharset()
$t->diag('::getCharset() ::setCharset()');
$t->is(sfValidatorBase::getCharset(), 'UTF-8', '::getCharset() returns the charset to use for validators');
sfValidatorBase::setCharset('ISO-8859-1');
$t->is(sfValidatorBase::getCharset(), 'ISO-8859-1', '::setCharset() changes the charset to use for validators');
// ->asString()
$t->diag('->asString()');
$v = new ValidatorIdentity();
$t->is($v->asString(), 'ValidatorIdentity()', '->asString() returns a string representation of the validator');
$v->setOption('required', false);
$v->setOption('foo', 'foo');
$t->is($v->asString(), 'ValidatorIdentity({ required: false, foo: foo })', '->asString() returns a string representation of the validator');
$v->setMessage('required', 'This is required.');
$t->is($v->asString(), 'ValidatorIdentity({ required: false, foo: foo }, { required: \'This is required.\' })', '->asString() returns a string representation of the validator');
$v = new ValidatorIdentity();
$v->setMessage('required', 'This is required.');
$t->is($v->asString(), 'ValidatorIdentity({}, { required: \'This is required.\' })', '->asString() returns a string representation of the validator');
// ::setDefaultMessage()
$t->diag('::setDefaultMessage()');
示例2: initConfiguration
/**
* @see sfProjectConfiguration
*/
public function initConfiguration()
{
$configCache = $this->getConfigCache();
// in debug mode, start global timer
if ($this->isDebug() && !sfWebDebugPanelTimer::isStarted()) {
sfWebDebugPanelTimer::startTime();
}
// required core classes for the framework
if (!sfConfig::get('sf_debug') && !sfConfig::get('sf_test') && !self::$coreLoaded) {
$configCache->import('config/core_compile.yml', false);
}
$this->dispatcher->connect('autoload.filter_config', array($this, 'filterAutoloadConfig'));
sfAutoload::getInstance()->register();
// load base settings
include $configCache->checkConfig('config/settings.yml');
if ($file = $configCache->checkConfig('config/app.yml', true)) {
include $file;
}
if (false !== sfConfig::get('sf_csrf_secret')) {
sfForm::enableCSRFProtection(sfConfig::get('sf_csrf_secret'));
}
sfWidget::setCharset(sfConfig::get('sf_charset'));
sfValidatorBase::setCharset(sfConfig::get('sf_charset'));
// force setting default timezone if not set
if ($default_timezone = sfConfig::get('sf_default_timezone')) {
date_default_timezone_set($default_timezone);
} else {
if (sfConfig::get('sf_force_default_timezone', true)) {
date_default_timezone_set(@date_default_timezone_get());
}
}
// error settings
ini_set('display_errors', $this->isDebug() ? 'on' : 'off');
error_reporting(sfConfig::get('sf_error_reporting'));
// initialize plugin configuration objects
$this->initializePlugins();
// Disabled by default in symfony 1.1 because it causes problems with Doctrine.
// If you want to enable it in your application, just copy the spl_autoload_register() line
// in your configuration class.
if (0 && $this->isDebug()) {
spl_autoload_register(array(sfAutoload::getInstance(), 'autoloadAgain'));
}
// compress output
if (!self::$coreLoaded) {
ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : '');
}
self::$coreLoaded = true;
}
示例3: initConfiguration
/**
* Various initializations.
*/
public function initConfiguration()
{
$configCache = $this->getConfigCache();
// in debug mode, start global timer
if ($this->isDebug() && !sfWebDebugPanelTimer::isStarted())
{
sfWebDebugPanelTimer::startTime();
}
// required core classes for the framework
if (!$this->isDebug() && !sfConfig::get('sf_test') && !self::$coreLoaded)
{
$configCache->import('config/core_compile.yml', false);
}
// autoloader(s)
$this->dispatcher->connect('autoload.filter_config', array($this, 'filterAutoloadConfig'));
sfAutoload::getInstance()->register();
if ($this->isDebug())
{
sfAutoloadAgain::getInstance()->register();
}
// load base settings
$this->beforeSettingsConfiguration();
include($configCache->checkConfig('config/settings.yml'));
if ($file = $configCache->checkConfig('config/app.yml', true))
{
include($file);
}
if (false !== sfConfig::get('sf_csrf_secret'))
{
sfForm::enableCSRFProtection(sfConfig::get('sf_csrf_secret'));
}
sfWidget::setCharset(sfConfig::get('sf_charset'));
sfValidatorBase::setCharset(sfConfig::get('sf_charset'));
// force setting default timezone if not set
if ($default_timezone = sfConfig::get('sf_default_timezone'))
{
date_default_timezone_set($default_timezone);
}
else if (sfConfig::get('sf_force_default_timezone', true))
{
date_default_timezone_set(@date_default_timezone_get());
}
// error settings
ini_set('display_errors', $this->isDebug() ? 'on' : 'off');
error_reporting(sfConfig::get('sf_error_reporting'));
// initialize plugin configuration objects
$this->initializePlugins();
// compress output
if (!self::$coreLoaded)
{
ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : null);
}
self::$coreLoaded = true;
}