Sfoglia il codice sorgente

merged branch lsmith77/forward_compat (PR #2526)

Commits
-------

b6bf018 tweaked error handling for the forward compatibility
dd606b5 added note about the purpose of this class
c1426ba added locale handling forward compatibility
10eed30 added MessageDataCollector forward compatibility

Discussion
----------

Forward compat

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #2522
Fabien Potencier 13 anni fa
parent
commit
60f8525ae5

+ 23 - 0
src/Symfony/Bridge/Swiftmailer/DataCollector/MessageDataCollector.php

@@ -0,0 +1,23 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Bridge\Swiftmailer\DataCollector;
+
+use Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector as BaseMessageDataCollector;
+
+/**
+ * MessageDataCollector.
+ *
+ * Added for forwards compatibility with Symfony2.1
+ */
+class MessageDataCollector extends BaseMessageDataCollector
+{
+}

+ 18 - 0
src/Symfony/Component/HttpFoundation/Request.php

@@ -845,6 +845,24 @@ class Request
         $this->format = $format;
     }
 
+    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();
+    }
+
     /**
      * Checks whether the method is safe or not.
      *