Feature: #103090 - Make link type label configurable
See forge#103090
Description
It is now possible to provide a translated label for custom link types.
For this, a new interface
\TYPO3\ has been
created, which offers the method
get for implementation.
That method can return the translated label.
The default abstract implementation
\TYPO3\ has been enhanced
to implement that interface. Any custom class extending this abstract is
able to override the method
get to provide the
custom translation.
Example extending the abstract:
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:
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
Labelled.
All existing custom implementations of the
Abstract class or the
Labelled
will continue to work as before, and will just continue to use the internal name of
the link type, instead of a translated label.