Deprecation: #106405 - AbstractTypolinkBuilder->build
See forge#106405
Description
The
build method in
\TYPO3\
has been deprecated in favor of the new
Typolink.
When creating custom TypolinkBuilder classes, the traditional approach of:
- Extending
AbstractTypolink Builder - Implementing the
buildmethod() - Receiving dependencies via constructor
This approach is now deprecated. The new recommended approach is to
implement the
Typolink.
The
Content property in
Abstract
is also deprecated and will be removed in TYPO3 v15.0. The
Content should be accessed via the
Server object instead.
Impact
Extension authors who have created custom TypolinkBuilder classes
extending from
Abstract will see deprecation
warnings when their link builders are used.
The deprecation warnings will be triggered when:
- Custom TypolinkBuilder classes still use the
buildmethod() - Code relies on the
$contentpropertyObject Renderer - The old constructor approach is used for dependency handling
Affected installations
TYPO3 installations with extensions that:
- Create custom TypolinkBuilder classes extending
AbstractTypolink Builder - Override or extend the
buildmethod() - Access the
$contentproperty directlyObject Renderer
Migration
For end users, generating links works the same way as before via:
ContentmethodObject Renderer->typolink () LinkclassFactory
No deprecation warnings will be triggered when using the public APIs.
For extension developers with custom TypolinkBuilder classes:
- Implement the new interface:
// Before (deprecated)
class MyCustomLinkBuilder extends AbstractTypolinkBuilder
{
public function build(array &$linkDetails, string $linkText, string $target, array $conf): LinkResultInterface
{
// Custom logic using $this->contentObjectRenderer
}
}
// After (recommended)
class MyCustomLinkBuilder implements TypolinkBuilderInterface
{
public function buildLink(array $linkDetails, array $configuration, ServerRequestInterface $request, string $linkText = ''): LinkResultInterface
{
$contentObjectRenderer = $request->getAttribute('currentContentObject');
// Custom logic using $contentObjectRenderer
}
}
- Use dependency injection for required services instead of accessing them via global state or constructor arguments.
- Access ContentObjectRenderer via the request object rather than the deprecated property.
Note: All implementations of
Typolink are automatically
configured as public services in the DI container - no manual service
configuration is needed.
Extensions can maintain backward compatibility during the transition period
by implementing both the old
build method and the new
build method.