本文整理汇总了PHP中sfStorage::read方法的典型用法代码示例。如果您正苦于以下问题:PHP sfStorage::read方法的具体用法?PHP sfStorage::read怎么用?PHP sfStorage::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfStorage
的用法示例。
在下文中一共展示了sfStorage::read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
/**
* Initializes this sfUser.
*
* Available options:
*
* * auto_shutdown: Whether to automatically save the changes to the session (true by default)
* * culture: The user culture
* * default_culture: The default user culture (en by default)
* * use_flash: Whether to enable flash usage (false by default)
* * logging: Whether to enable logging (false by default)
*
* @param sfEventDispatcher $dispatcher An sfEventDispatcher instance.
* @param sfStorage $storage An sfStorage instance.
* @param array $options An associative array of options.
*
* @return Boolean true, if initialization completes successfully, otherwise false.
*/
public function initialize(sfEventDispatcher $dispatcher, sfStorage $storage, $options = array())
{
$this->dispatcher = $dispatcher;
$this->storage = $storage;
$this->options = array_merge(array('auto_shutdown' => true, 'culture' => null, 'default_culture' => 'en', 'use_flash' => false, 'logging' => false), $options);
$this->attributeHolder = new sfNamespacedParameterHolder(self::ATTRIBUTE_NAMESPACE);
// read attributes from storage
$attributes = $storage->read(self::ATTRIBUTE_NAMESPACE);
if (is_array($attributes)) {
foreach ($attributes as $namespace => $values) {
$this->attributeHolder->add($values, $namespace);
}
}
// set the user culture to sf_culture parameter if present in the request
// otherwise
// - use the culture defined in the user session
// - use the default culture set in settings.yml
$currentCulture = $storage->read(self::CULTURE_NAMESPACE);
$this->setCulture(null !== $this->options['culture'] ? $this->options['culture'] : (null !== $currentCulture ? $currentCulture : $this->options['default_culture']));
// flag current flash to be removed at shutdown
if ($this->options['use_flash'] && ($names = $this->attributeHolder->getNames('symfony/user/sfUser/flash'))) {
if ($this->options['logging']) {
$this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Flag old flash messages ("%s")', implode('", "', $names)))));
}
foreach ($names as $name) {
$this->attributeHolder->set($name, true, 'symfony/user/sfUser/flash/remove');
}
}
}
示例2: initialize
public function initialize(sfEventDispatcher $dispatcher, sfStorage $storage, $options = array())
{
$this->dispatcher = $dispatcher;
$this->storage = $storage;
$this->options = array_merge(array('auto_shutdown' => true, 'culture' => null, 'default_culture' => 'en', 'use_flash' => false, 'logging' => false), $options);
$this->attributeHolder = new sfNamespacedParameterHolder(self::ATTRIBUTE_NAMESPACE);
$attributes = $storage->read(self::ATTRIBUTE_NAMESPACE);
if (is_array($attributes)) {
foreach ($attributes as $namespace => $values) {
$this->attributeHolder->add($values, $namespace);
}
}
$currentCulture = $storage->read(self::CULTURE_NAMESPACE);
$this->setCulture(!is_null($this->options['culture']) ? $this->options['culture'] : (!is_null($currentCulture) ? $currentCulture : $this->options['default_culture']));
if ($this->options['use_flash'] && ($names = $this->attributeHolder->getNames('symfony/user/sfUser/flash'))) {
if ($this->options['logging']) {
$this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Flag old flash messages ("%s")', implode('", "', $names)))));
}
foreach ($names as $name) {
$this->attributeHolder->set($name, true, 'symfony/user/sfUser/flash/remove');
}
}
}