‪TYPO3CMS  ‪main
LegacyLinkBuilder.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 
27 {
28  public function ‪build(array &$linkDetails, string $linkText, string $target, array $conf): ‪LinkResultInterface
29  {
30  $tsfe = $this->‪getTypoScriptFrontendController();
31  if ($linkDetails['file'] ?? false) {
32  $linkDetails['type'] = ‪LinkService::TYPE_FILE;
33  $linkLocation = $linkDetails['file'];
34  // Setting title if blank value to link
35  $linkText = $this->‪encodeFallbackLinkTextIfLinkTextIsEmpty($linkText, rawurldecode($linkLocation));
36  $linkLocation = (!str_starts_with($linkLocation, '/') ? $tsfe->absRefPrefix : '') . $linkLocation;
37  ‪$url = $linkLocation;
38  ‪$url = $this->‪forceAbsoluteUrl(‪$url, $conf);
39  $target = $target ?: $this->‪resolveTargetAttribute($conf, 'fileTarget');
40  } elseif ($linkDetails['url'] ?? false) {
41  $linkDetails['type'] = ‪LinkService::TYPE_URL;
42  $target = $target ?: $this->‪resolveTargetAttribute($conf, 'extTarget');
43  $linkText = $this->‪encodeFallbackLinkTextIfLinkTextIsEmpty($linkText, $linkDetails['url']);
44  ‪$url = $linkDetails['url'];
45  } else {
46  throw new ‪UnableToLinkException('Unknown link detected, so ' . $linkText . ' was not linked.', 1490990031, null, $linkText);
47  }
48  return (new LinkResult((string)$linkDetails['type'], (string)‪$url))->withTarget($target)->withLinkConfiguration($conf)->withLinkText($linkText);
49  }
50 }
‪TYPO3\CMS\Webhooks\Message\$url
‪identifier readonly UriInterface $url
Definition: LoginErrorOccurredMessage.php:36