From ab50ba11818cc688d77b8dfadfa0d209828a3bdd Mon Sep 17 00:00:00 2001 From: rinkp Date: Wed, 24 Jul 2024 22:54:49 +0200 Subject: [PATCH] [style] Main function goes on top --- .../DispatchErrorFormatterListener.php | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/module/User/src/Listener/DispatchErrorFormatterListener.php b/module/User/src/Listener/DispatchErrorFormatterListener.php index d2493326..0778af55 100644 --- a/module/User/src/Listener/DispatchErrorFormatterListener.php +++ b/module/User/src/Listener/DispatchErrorFormatterListener.php @@ -19,6 +19,36 @@ final class DispatchErrorFormatterListener { + public function __invoke(MvcEvent $e): void + { + /** + * The source code is public so we can give away 404 errors if it is because of no route + * This does not include 404 responses that are returned by logic, such as when a member does not exist + **/ + if ('error-router-no-match' === $e->getError()) { + $this->handleNoMatchedRoute($e); + + return; + } + + /** + * If this is not an error-router-no-match error, we must have a matching route + */ + $match = $e->getRouteMatch(); + + // We should always have a match here; if we do not, throw an exception + // possibly including previous exceptions + if (null === $match) { + throw new LogicException( + message: 'Assumed route would be present; no route present', + previous: $e->getParam('exception', null), + ); + } + + // If we do have a match, this implies we have properly authenticated before + $this->handleMatchedRoute($e, $match); + } + private function matchAncestorRoute( Request $request, Router $router, @@ -107,34 +137,4 @@ private function handleMatchedRoute( $e->stopPropagation(); } - - public function __invoke(MvcEvent $e): void - { - /** - * The source code is public so we can give away 404 errors if it is because of no route - * This does not include 404 responses that are returned by logic, such as when a member does not exist - **/ - if ('error-router-no-match' === $e->getError()) { - $this->handleNoMatchedRoute($e); - - return; - } - - /** - * If this is not an error-router-no-match error, we must have a matching route - */ - $match = $e->getRouteMatch(); - - // We should always have a match here; if we do not, throw an exception - // possibly including previous exceptions - if (null === $match) { - throw new LogicException( - message: 'Assumed route would be present; no route present', - previous: $e->getParam('exception', null), - ); - } - - // If we do have a match, this implies we have properly authenticated before - $this->handleMatchedRoute($e, $match); - } }