Important: #79647 - Added Hook for resolving custom link types
See forge#79647
Description
A newly introduced hook in Link
allows to resolve custom link types with
special syntax. A reference to the empty $result
array is passed as well as the $urn
string that could not be
resolved by the core.
Example
An example implementation for custom links that use my
as a prefix could look like this:
EXT:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['Link']['resolveByStringRepresentation'][] =
\MyVendor\MySite\Hooks\LinkServiceHook::class . '->resolveByStringRepresentation';
Copied!
EXT:
namespace MyVendor\MySite\Hooks;
class LinkServiceHook
{
public function resolveByStringRepresentation(array $parameters): void
{
// Only care for links that start with myLinkIdentifier:
if (stripos($parameters['urn'], 'myLinkIdentifier:') !== 0) {
return;
}
// Be aware: substr of 17 because of the identifier and the colon
$parameters['result'] = ['myLinkIdentifier' => substr($parameters['urn'], 17)];
$parameters['result']['type'] = 'myLinkIdentifier';
}
}
Copied!