| Conditions | 4 |
| Paths | 7 |
| Total Lines | 21 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | public function addLanguageParameterByDetection(array $linkDetails, ?ServerRequestInterface $request = null): array |
||
| 28 | { |
||
| 29 | if ($linkDetails['type'] !== LinkService::TYPE_PAGE) { |
||
| 30 | return $linkDetails; |
||
| 31 | } |
||
| 32 | |||
| 33 | if ($request === null) { |
||
| 34 | $request = ServerRequestFactory::fromGlobals(); |
||
| 35 | $request = $request->withMethod('GET')->withUri(new Uri('/')); |
||
| 36 | } |
||
| 37 | |||
| 38 | $request = $request->withAttribute('site', $this->languageSiteFinder->getSiteByPageId((int)$linkDetails['pageuid'] ?? 0)); |
||
| 39 | |||
| 40 | try { |
||
| 41 | $response = $this->linkLanguageHandler->handle($request); |
||
| 42 | |||
| 43 | $linkDetails['parameters'] = 'L=' . $response->getHeaderLine(LinkLanguageHandler::HEADER_NAME); |
||
| 44 | |||
| 45 | return $linkDetails; |
||
| 46 | } catch (AbstractHandlerException $exception) { |
||
| 47 | return $linkDetails; |
||
| 48 | } |
||
| 51 |