| Conditions | 7 |
| Paths | 13 |
| Total Lines | 51 |
| Code Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 81 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
||
| 82 | { |
||
| 83 | /** @var Route $route */ |
||
| 84 | $route = $request->getAttribute('route'); |
||
| 85 | |||
| 86 | // The global must be available very early, because methods below |
||
| 87 | // might trigger code which relies on it. See: #45625 |
||
| 88 | $GLOBALS['BE_USER'] = GeneralUtility::makeInstance(BackendUserAuthentication::class); |
||
| 89 | try { |
||
| 90 | $GLOBALS['BE_USER']->start(); |
||
| 91 | } catch (MfaRequiredException $mfaRequiredException) { |
||
| 92 | // If MFA is required and we are not already on the "auth_mfa" |
||
| 93 | // route, force the user to it for further authentication |
||
| 94 | if ($route->getOption('_identifier') !== 'auth_mfa') { |
||
| 95 | return $this->redirectToMfaAuthProcess($GLOBALS['BE_USER'], $mfaRequiredException->getProvider(), $request); |
||
| 96 | } |
||
| 97 | } |
||
| 98 | |||
| 99 | // Register the backend user as aspect and initializing workspace once for TSconfig conditions |
||
| 100 | $this->setBackendUserAspect($GLOBALS['BE_USER'], (int)($GLOBALS['BE_USER']->user['workspace_id'] ?? 0)); |
||
| 101 | if ($this->isLoggedInBackendUserRequired($route)) { |
||
| 102 | if (!$this->context->getAspect('backend.user')->isLoggedIn()) { |
||
|
|
|||
| 103 | $uri = GeneralUtility::makeInstance(UriBuilder::class)->buildUriWithRedirect( |
||
| 104 | 'login', |
||
| 105 | [], |
||
| 106 | $route->getOption('_identifier'), |
||
| 107 | $request->getQueryParams() |
||
| 108 | ); |
||
| 109 | $response = new RedirectResponse($uri); |
||
| 110 | return $this->enrichResponseWithHeadersAndCookieInformation($response, $GLOBALS['BE_USER']); |
||
| 111 | } |
||
| 112 | if (!$GLOBALS['BE_USER']->isUserAllowedToLogin()) { |
||
| 113 | $content = GeneralUtility::makeInstance(ErrorPageController::class)->errorAction( |
||
| 114 | 'Login Error', |
||
| 115 | 'TYPO3 is in maintenance mode at the moment. Only administrators are allowed access.', |
||
| 116 | AbstractMessage::ERROR, |
||
| 117 | 1294585860 |
||
| 118 | ); |
||
| 119 | $response = new HtmlResponse($content, 503); |
||
| 120 | return $this->enrichResponseWithHeadersAndCookieInformation($response, $GLOBALS['BE_USER']); |
||
| 121 | } |
||
| 122 | } |
||
| 123 | if ($this->context->getAspect('backend.user')->isLoggedIn()) { |
||
| 124 | $GLOBALS['BE_USER']->initializeBackendLogin(); |
||
| 125 | } |
||
| 126 | $GLOBALS['LANG'] = $this->languageServiceFactory->createFromUserPreferences($GLOBALS['BE_USER']); |
||
| 127 | // Re-setting the user and take the workspace from the user object now |
||
| 128 | $this->setBackendUserAspect($GLOBALS['BE_USER']); |
||
| 129 | $response = $handler->handle($request); |
||
| 130 | $this->sessionGarbageCollection(); |
||
| 131 | return $this->enrichResponseWithHeadersAndCookieInformation($response, $GLOBALS['BE_USER']); |
||
| 132 | } |
||
| 213 |