Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Add hook for resolving custom link types
The extendability of the link wizard is incomplete since the refactoring of it. This patch adds a missing hook to resolve custom link syntax in the LinkService. It is now possible (again) to resolve links that start with <identifier>: Resolves: #79647 Releases: master, 8.7 Change-Id: Iaf0c18f72aa799ab44a8bd14bddd0ca6c3530198 Reviewed-on: https://review.typo3.org/56730 Reviewed-by: Markus Klein <markus.klein@typo3.org> Tested-by: Markus Klein <markus.klein@typo3.org> Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Frans Saris <franssaris@gmail.com> Reviewed-by: Riny van Tiggelen <info@online-gamer.nl> Reviewed-by: Joerg Boesche <typo3@joergboesche.de> Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com> Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
- Loading branch information
Showing
2 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...tation/Changelog/8.7.x/Important-79647-AddedHookForResolvingCustomLinkTypes.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
.. include:: ../../Includes.txt | ||
|
||
============================================================== | ||
Important: #79647 - Added Hook for resolving custom link types | ||
============================================================== | ||
|
||
See :issue:`79647` | ||
|
||
Description | ||
=========== | ||
|
||
A newly introduced hook in :php:`LinkService->resolveByStringRepresentation` allows to resolve custom link types with | ||
special syntax. A reference to the empty :php:`$result` array is passed as well as the :php:`$urn` string that could not be | ||
resolved by the core. | ||
|
||
Example | ||
======= | ||
|
||
An example implementation for custom links that use `myLinkIdentifier:` as a prefix could look like this: | ||
|
||
:file:`EXT:my_site/ext_localconf.php` | ||
|
||
.. code-block:: php | ||
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['Link']['resolveByStringRepresentation'][] = | ||
\MyVendor\MySite\Hooks\LinkServiceHook::class . '->resolveByStringRepresentation'; | ||
:file:`EXT:my_site/Classes/Hooks/LinkServiceHook.php` | ||
|
||
.. code-block:: php | ||
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; | ||
} | ||
$parameters['result'] = ['myLinkIdentifier' => substr($parameters['urn'], 17)] | ||
$parameters['result']['type'] = 'myLinkIdentifier'; | ||
} | ||
} | ||
.. index:: Backend, PHP-API |