1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Lochmueller\LanguageDetection\Handler; |
||
6 | |||
7 | use Lochmueller\LanguageDetection\Event\BuildResponseEvent; |
||
8 | use Lochmueller\LanguageDetection\Event\CheckLanguageDetectionEvent; |
||
9 | use Lochmueller\LanguageDetection\Event\DetectUserLanguagesEvent; |
||
10 | use Lochmueller\LanguageDetection\Event\NegotiateSiteLanguageEvent; |
||
11 | use Lochmueller\LanguageDetection\Handler\Exception\DisableLanguageDetectionException; |
||
0 ignored issues
–
show
|
|||
12 | use Lochmueller\LanguageDetection\Handler\Exception\NoResponseException; |
||
0 ignored issues
–
show
The type
Lochmueller\LanguageDete...ion\NoResponseException was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
13 | use Lochmueller\LanguageDetection\Handler\Exception\NoSelectedLanguageException; |
||
0 ignored issues
–
show
The type
Lochmueller\LanguageDete...lectedLanguageException was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
14 | use Lochmueller\LanguageDetection\Handler\Exception\NoUserLanguagesException; |
||
0 ignored issues
–
show
The type
Lochmueller\LanguageDete...oUserLanguagesException was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
15 | use Psr\Http\Message\ResponseInterface; |
||
16 | use Psr\Http\Message\ServerRequestInterface; |
||
17 | use Psr\Http\Server\RequestHandlerInterface; |
||
18 | |||
19 | /** |
||
20 | * Core handler for handling the language detection, with all 4 core events. |
||
21 | * Called via regular main middleware and check all page settings. |
||
22 | */ |
||
23 | class LanguageDetectionHandler extends AbstractHandler implements RequestHandlerInterface |
||
0 ignored issues
–
show
The type
Lochmueller\LanguageDete...Handler\AbstractHandler was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
24 | { |
||
25 | public function handle(ServerRequestInterface $request): ResponseInterface |
||
26 | { |
||
27 | $site = $this->getSiteFromRequest($request); |
||
28 | |||
29 | $check = new CheckLanguageDetectionEvent($site, $request); |
||
30 | $this->eventDispatcher->dispatch($check); |
||
31 | |||
32 | if (!$check->isLanguageDetectionEnable()) { |
||
33 | throw new DisableLanguageDetectionException(); |
||
34 | } |
||
35 | |||
36 | $detect = new DetectUserLanguagesEvent($site, $request); |
||
37 | $this->eventDispatcher->dispatch($detect); |
||
38 | |||
39 | if ($detect->getUserLanguages()->isEmpty()) { |
||
40 | throw new NoUserLanguagesException(); |
||
41 | } |
||
42 | |||
43 | $negotiate = new NegotiateSiteLanguageEvent($site, $request, $detect->getUserLanguages()); |
||
44 | $this->eventDispatcher->dispatch($negotiate); |
||
45 | |||
46 | if ($negotiate->getSelectedLanguage() === null) { |
||
47 | throw new NoSelectedLanguageException(); |
||
48 | } |
||
49 | |||
50 | $response = new BuildResponseEvent($site, $request, $negotiate->getSelectedLanguage()); |
||
51 | $this->eventDispatcher->dispatch($response); |
||
52 | |||
53 | if ($response->getResponse() === null) { |
||
54 | throw new NoResponseException(); |
||
55 | } |
||
56 | |||
57 | return $response->getResponse(); |
||
58 | } |
||
59 | } |
||
60 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths