瀏覽代碼

[HttpFoundation] fixed locale accessors in Session class

ornicar 14 年之前
父節點
當前提交
9588860716
共有 1 個文件被更改,包括 5 次插入4 次删除
  1. 5 4
      src/Symfony/Component/HttpFoundation/Session.php

+ 5 - 4
src/Symfony/Component/HttpFoundation/Session.php

@@ -21,7 +21,6 @@ use Symfony\Component\HttpFoundation\SessionStorage\SessionStorageInterface;
 class Session implements \Serializable
 {
     protected $storage;
-    protected $locale;
     protected $attributes;
     protected $oldFlashes;
     protected $started;
@@ -171,7 +170,7 @@ class Session implements \Serializable
             $this->start();
         }
 
-        return $this->getAttribute('_locale');
+        return $this->attributes['_locale'];
     }
 
     /**
@@ -181,9 +180,11 @@ class Session implements \Serializable
      */
     public function setLocale($locale)
     {
-        if ($this->locale != $locale) {
-            $this->setAttribute('_locale', $locale);
+        if (false === $this->started) {
+            $this->start();
         }
+
+        $this->attributes['_locale'] = $locale;
     }
 
     public function getFlashMessages()