Skip to content

Commit

Permalink
[style] Main function goes on top
Browse files Browse the repository at this point in the history
  • Loading branch information
rinkp committed Jul 24, 2024
1 parent 057d40d commit ab50ba1
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions module/User/src/Listener/DispatchErrorFormatterListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
}

0 comments on commit ab50ba1

Please sign in to comment.