2 declare(strict_types = 1);
49 if (!empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'linkHandler'])) {
50 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'linkHandler'] as $type => $handler) {
51 if (!isset($this->handlers[$type]) || !is_object($this->handlers[$type])) {
52 $this->handlers[$type] = GeneralUtility::makeInstance($handler);
74 public function resolve(
string $linkParameter): array
80 $legacyLinkNotationConverter = GeneralUtility::makeInstance(LegacyLinkNotationConverter::class);
81 return $legacyLinkNotationConverter->resolve($linkParameter);
96 if (stripos($urn,
't3://') === 0) {
98 $urnParsed = parse_url($urn);
99 $type = $urnParsed[
'host'];
100 if (isset($urnParsed[
'query'])) {
101 parse_str(htmlspecialchars_decode($urnParsed[
'query']), $data);
105 $fragment = $urnParsed[
'fragment'] ??
null;
107 if (is_object($this->handlers[$type])) {
108 $result = $this->handlers[$type]->resolveHandlerData($data);
109 $result[
'type'] = $type;
111 throw new Exception\UnknownLinkHandlerException(
'LinkHandler for ' . $type .
' was not registered', 1460581769);
115 $result[
'fragment'] = $fragment;
117 } elseif (stripos($urn,
'://') && $this->handlers[self::TYPE_URL]) {
118 $result = $this->handlers[
self::TYPE_URL]->resolveHandlerData([
'url' => $urn]);
120 } elseif (stripos($urn,
'mailto:') === 0 && $this->handlers[self::TYPE_EMAIL]) {
121 $result = $this->handlers[
self::TYPE_EMAIL]->resolveHandlerData([
'email' => $urn]);
125 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'Link'][
'resolveByStringRepresentation'] ??
null)) {
126 $params = [
'urn' => $urn,
'result' => &$result];
127 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'Link'][
'resolveByStringRepresentation'] as $hookMethod) {
129 GeneralUtility::callUserFunction($hookMethod, $params, $fakeThis);
132 if (empty($result) || empty($result[
'type'])) {
133 throw new Exception\UnknownUrnException(
'No valid URN to resolve found', 1457177667);
153 public function asString(array $parameters): string
155 if (is_object($this->handlers[$parameters[
'type']])) {
156 return $this->handlers[$parameters[
'type']]->asString($parameters);
158 if (isset($parameters[
'url']) && !empty($parameters[
'url'])) {
161 return $parameters[
'url'];
163 throw new Exception\UnknownLinkHandlerException(
'No valid handlers found for type: ' . $parameters[
'type'], 1460629247);