Explorar o código

tweaked error handling for the forward compatibility

Lukas Kahwe Smith %!s(int64=13) %!d(string=hai) anos
pai
achega
b6bf0182e9
Modificáronse 1 ficheiros con 8 adicións e 5 borrados
  1. 8 5
      src/Symfony/Component/HttpFoundation/Request.php

+ 8 - 5
src/Symfony/Component/HttpFoundation/Request.php

@@ -845,18 +845,21 @@ class Request
         $this->format = $format;
     }
 
-    public function setDefaultLocale($locale)
-    {
-        $this->session->setPhpDefaultLocale($locale);
-    }
-
     public function setLocale($locale)
     {
+        if (!$this->hasSession()) {
+            throw new \LogicException('Forward compatibility for Request::setLocale() requires the session to be set.');
+        }
+
         $this->session->setLocale($locale);
     }
 
     public function getLocale()
     {
+        if (!$this->hasSession()) {
+            throw new \LogicException('Forward compatibility for Request::getLocale() requires the session to be set.');
+        }
+
         return $this->session->getLocale();
     }