You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[FEATURE] Allow custom linktype labels in EXT:linkvalidator
If a custom linktype is registered for the Linkvalidator, it is now
possible to define the label which will be displayed in the
backend module.
A new interface LabelledLinktypeInterface provides a method getReadableName() to return the custom label. It is implemented
by default in the AbstractLinktype class, so any custom
linktype extending from this will be able to override the method.
When no abstract class is extended, compositing a class
with the LabelledLinktypeInterface implementation is possible.
.. include:: /Includes.rst.txt
.. _feature-103090-1707479280:
===================================================
Feature: #103090 - Make linktype label configurable
===================================================
See :issue:`103090`
Description
===========
It is now possible to provide a translated label for custom linktypes.
For this, a new interface
:php:`\TYPO3\CMS\Linkvalidator\Linktype\LabelledLinktypeInterface` has been
created, which offers the method :php:`getReadableName` for implementation.
That method can return the translated label.
The default abstract implementation
:php:`\TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype` has been enhanced
to implement that interface. Any custom class extending this abstract is
able to override the method :php:`getReadableName` to provide the
custom translation.
Example extending the abstract:
-------------------------------
.. code-block:: php :caption: EXT:extension/Classes/Linktype/CustomLinktype.php use TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype; #[Autoconfigure(public: true)] class CustomLinktype extends AbstractLinktype { public function getReadableName(): string { $type = $this->getIdentifier(); return $this->getLanguageService()->sL( 'LLL:EXT:linkvalidator_example/Resources/Private/Language/Module/locallang.xlf:linktype_' . $type ) ?: $type; } }
Example implementing the interface:
-----------------------------------
.. code-block:: php :caption: EXT:extension/Classes/Linktype/CustomLinktype.php use TYPO3\CMS\Linkvalidator\Linktype\LinktypeInterface; use TYPO3\CMS\Linkvalidator\Linktype\LabelledLinktypeInterface; #[Autoconfigure(public: true)] class CustomLinktype implements LinktypeInterface, LabelledLinktypeInterface { // implement all LinktypeInterface methods: // getIdentifier, checkLink, setAdditionalConfig, ... // Implement the LabelledLinktypeInterface method getReadableName() public function getReadableName(): string { $type = $this->getIdentifier(); return $this->getLanguageService()->sL( 'LLL:EXT:linkvalidator_example/Resources/Private/Language/Module/locallang.xlf:linktype_' . $type ) ?: $type; } }
Impact
======
Custom linktype classes should now configure a label by implementing the method
:php:`LabelledLinktypeInterface::getReadableName()`.
All existing custom implementations of the `AbstractLinktype` class or the `LinktypeInterface`
will continue to work as before, and will just continue to use the internal name of
the linktype, instead of a translated label.
.. index:: Backend, ext:linkvalidator
The text was updated successfully, but these errors were encountered:
ℹ️ View this commit on Github
👥 Authored by Sybille Peters [email protected]
✔️ Merged by Stefan Bürk [email protected]
Commit message
[FEATURE] Allow custom linktype labels in EXT:linkvalidator
If a custom linktype is registered for the Linkvalidator, it is now
possible to define the label which will be displayed in the
backend module.
A new interface
LabelledLinktypeInterface
provides a methodgetReadableName()
to return the custom label. It is implementedby default in the
AbstractLinktype
class, so any customlinktype extending from this will be able to override the method.
When no abstract class is extended, compositing a class
with the
LabelledLinktypeInterface
implementation is possible.Resolves: #103090
Releases: main
Change-Id: I8255aca6529d104be19c8af2b7cd505cd8749d7d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82876
Tested-by: core-ci [email protected]
Reviewed-by: Garvin Hicking [email protected]
Tested-by: Stefan Bürk [email protected]
Reviewed-by: Stefan Bürk [email protected]
Tested-by: Garvin Hicking [email protected]
➕ Added files
13.3/Feature-103090-MakeLinktypeLabelConfigurable.rst
The text was updated successfully, but these errors were encountered: