Skip to content

Commit

Permalink
chore: clean up and reorder source code
Browse files Browse the repository at this point in the history
  • Loading branch information
malteriechmann committed Apr 11, 2023
1 parent 753fc55 commit 7c60f0a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Classes/Middleware/LanguageRedirectionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ class LanguageRedirectionMiddleware implements MiddlewareInterface
{
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
// Do nothing, if a HTTP referer is set
// Do nothing, if HTTP referer header is set
if (! empty($request->getServerParams()['HTTP_REFERER'])) {
return $handler->handle($request);
}

// Do nothing, if HTTP accept language header is not set
if (empty($request->getServerParams()['HTTP_ACCEPT_LANGUAGE'])) {
return $handler->handle($request);
}

// Get the website's configured site languages
$siteLanguages = $request->getAttribute('site')->getLanguages();

Expand All @@ -36,11 +41,6 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
return $handler->handle($request);
}

// Do nothing, if accept language header is not set
if (empty($request->getServerParams()['HTTP_ACCEPT_LANGUAGE'])) {
return $handler->handle($request);
}

// Get the ISO codes of the browser languages from HTTP request header
$browserLanguageIsoCodes = $this->getBrowserLangugeIsoCodes($request->getServerParams()['HTTP_ACCEPT_LANGUAGE']);

Expand Down

0 comments on commit 7c60f0a

Please sign in to comment.