Passed
Push — master ( 682083...f429aa )
by
unknown
13:05
created

BackendRequestHandler::getPriority()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the TYPO3 CMS project.
5
 *
6
 * It is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License, either version 2
8
 * of the License, or any later version.
9
 *
10
 * For the full copyright and license information, please read the
11
 * LICENSE.txt file that was distributed with this source code.
12
 *
13
 * The TYPO3 project - inspiring people to share!
14
 */
15
16
namespace TYPO3\CMS\Extbase\Mvc\Web;
17
18
use Psr\Http\Message\ResponseInterface;
19
use TYPO3\CMS\Core\Core\Environment;
20
use TYPO3\CMS\Extbase\Mvc\Dispatcher;
21
use TYPO3\CMS\Extbase\Mvc\Exception\InfiniteLoopException;
22
use TYPO3\CMS\Extbase\Mvc\RequestHandlerInterface;
23
use TYPO3\CMS\Extbase\Mvc\RequestInterface;
24
use TYPO3\CMS\Extbase\Service\EnvironmentService;
25
26
/**
27
 * A request handler which can handle web requests invoked by the backend.
28
 * @internal only to be used within Extbase, not part of TYPO3 Core API.
29
 */
30
class BackendRequestHandler implements RequestHandlerInterface
31
{
32
    protected Dispatcher $dispatcher;
33
    protected EnvironmentService $environmentService;
34
35
    public function __construct(
36
        Dispatcher $dispatcher,
37
        EnvironmentService $environmentService
38
    ) {
39
        $this->dispatcher = $dispatcher;
40
        $this->environmentService = $environmentService;
41
    }
42
43
    /**
44
     * Handles the web request. The response will automatically be sent to the client.
45
     *
46
     * @param RequestInterface $request
47
     * @return ResponseInterface
48
     * @throws InfiniteLoopException
49
     */
50
    public function handleRequest(RequestInterface $request)
51
    {
52
        return $this->dispatcher->dispatch($request);
53
    }
54
55
    /**
56
     * This request handler can handle a web request invoked by the backend.
57
     *
58
     * @param RequestInterface $request
59
     * @return bool If we are in backend mode TRUE otherwise FALSE
60
     */
61
    public function canHandleRequest(RequestInterface $request)
62
    {
63
        return $this->environmentService->isEnvironmentInBackendMode() && !Environment::isCli();
64
    }
65
66
    public function getPriority(): int
67
    {
68
        return 100;
69
    }
70
}
71