2 namespace TYPO3\CMS\Core\LinkHandling
;
5 * This file is part of the TYPO3 CMS project.
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
18 * Resolves URLs (simple, no magic needed)
20 class UrlLinkHandler
implements LinkHandlingInterface
24 * Returns the URL as given
26 * @param array $parameters
29 public function asString(array $parameters): string
31 return $this->addHttpSchemeAsFallback($parameters['url']);
35 * Returns the URL as is
37 * @param array $data (needs 'url') inside
40 public function resolveHandlerData(array $data): array
42 return ['url' => $this->addHttpSchemeAsFallback($data['url'])];
46 * Ensures that a scheme is always added, if www.typo3.org was added previously
48 * @param string $url the URL
51 protected function addHttpSchemeAsFallback(string $url): string
54 $urlParts = parse_url($url);
55 if (empty($urlParts['scheme'])) {
56 $url = 'http://' . $url;