فهرست منبع

Merge remote branch 'theinterned/patch-1'

* theinterned/patch-1:
  made logoutPath localizable as well
  storing localized targetPath in a string as opposed to updating the attribute
  In the spirit of 882a8e3f09c602a6f0ed3b5bd20e8d4688331500 allow for localized logout target url
Fabien Potencier 14 سال پیش
والد
کامیت
afa30d9864
1فایلهای تغییر یافته به همراه5 افزوده شده و 2 حذف شده
  1. 5 2
      src/Symfony/Component/Security/Http/Firewall/LogoutListener.php

+ 5 - 2
src/Symfony/Component/Security/Http/Firewall/LogoutListener.php

@@ -69,7 +69,10 @@ class LogoutListener implements ListenerInterface
     {
         $request = $event->getRequest();
 
-        if ($this->logoutPath !== $request->getPathInfo()) {
+        $logoutPath = str_replace('{_locale}', $request->getSession()->getLocale(), $this->logoutPath);
+        $targetUrl = str_replace('{_locale}', $request->getSession()->getLocale(), $this->targetUrl);
+        
+        if ($logoutPath !== $request->getPathInfo()) {
             return;
         }
 
@@ -80,7 +83,7 @@ class LogoutListener implements ListenerInterface
                 throw new \RuntimeException('Logout Success Handler did not return a Response.');
             }
         } else {
-            $response = new RedirectResponse(0 !== strpos($this->targetUrl, 'http') ? $request->getUriForPath($this->targetUrl) : $this->targetUrl, 302);
+            $response = new RedirectResponse(0 !== strpos($targetUrl, 'http') ? $request->getUriForPath($targetUrl) : $targetUrl, 302);
         }
 
         // handle multiple logout attempts gracefully