From 0636bf537843f20b2d938ed88e55220dd89f58a4 Mon Sep 17 00:00:00 2001 From: Maxime Veber Date: Wed, 28 Nov 2018 14:42:41 +0100 Subject: [PATCH] Remove goto in RedirectableUrlMatcher --- .../Matcher/RedirectableUrlMatcher.php | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php b/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php index e60552f158230..db3d71d59ea87 100644 --- a/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php @@ -32,18 +32,7 @@ public function match($pathinfo) } if ($this->allowSchemes) { - redirect_scheme: - $scheme = $this->context->getScheme(); - $this->context->setScheme(current($this->allowSchemes)); - try { - $ret = parent::match($pathinfo); - - return $this->redirect($pathinfo, $ret['_route'] ?? null, $this->context->getScheme()) + $ret; - } catch (ExceptionInterface $e2) { - throw $e; - } finally { - $this->context->setScheme($scheme); - } + return $this->redirectScheme($pathinfo, $e); } elseif ('/' === $pathinfo) { throw $e; } else { @@ -54,11 +43,26 @@ public function match($pathinfo) return $this->redirect($pathinfo, $ret['_route'] ?? null) + $ret; } catch (ExceptionInterface $e2) { if ($this->allowSchemes) { - goto redirect_scheme; + return $this->redirectScheme($pathinfo, $e); } throw $e; } } } } + + private function redirectScheme(string $pathinfo, ResourceNotFoundException $originalException) + { + $scheme = $this->context->getScheme(); + $this->context->setScheme(current($this->allowSchemes)); + try { + $ret = parent::match($pathinfo); + + return $this->redirect($pathinfo, $ret['_route'] ?? null, $this->context->getScheme()) + $ret; + } catch (ExceptionInterface $e) { + throw $originalException; + } finally { + $this->context->setScheme($scheme); + } + } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy