‪TYPO3CMS  11.5
LinkResultFactory.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 
22 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
23 
28 {
30 
32  {
33  $this->linkService = ‪$linkService;
34  }
35 
36  public function ‪createFromUriString(string $uri): ‪LinkResultInterface
37  {
38  $linkDetails = $this->linkService->resolve($uri);
39  $linkDetails['typoLinkParameter'] = $uri;
40  $linkType = $linkDetails['type'] ?? '';
41 
42  $linkBuilder = $this->‪resolveLinkBuilder($linkType);
43  if ($linkBuilder !== null) {
44  return $linkBuilder->build($linkDetails, '', '', []);
45  }
46  return GeneralUtility::makeInstance(
47  LinkResult::class,
48  $linkDetails['type'] ?? '',
49  $linkDetails['url'] ?? $uri
50  );
51  }
52 
53  protected function ‪resolveLinkBuilder(string $linkType): ?‪AbstractTypolinkBuilder
54  {
55  $className = (string)(‪$GLOBALS['TYPO3_CONF_VARS']['FE']['typolinkBuilder'][$linkType] ?? '');
56  if (!is_a($className, AbstractTypolinkBuilder::class, true)) {
57  return null;
58  }
59  $contentObjectRenderer = GeneralUtility::makeInstance(ContentObjectRenderer::class);
60  return GeneralUtility::makeInstance($className, $contentObjectRenderer);
61  }
62 }
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50