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


PHP sfStorage::read方法代碼示例

本文整理匯總了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');
         }
     }
 }
開發者ID:cuongnv540,項目名稱:jobeet,代碼行數:46,代碼來源:sfUser.class.php

示例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');
         }
     }
 }
開發者ID:BGCX261,項目名稱:zoorestaurant-svn-to-git,代碼行數:23,代碼來源:config_core_compile.yml.php


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