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
Abstract
Typolink Builder - Implementing the
build
method() - 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
build
method() - Code relies on the
$content
propertyObject Renderer - The old constructor approach is used for dependency handling
Affected installations
TYPO3 installations with extensions that:
- Create custom TypolinkBuilder classes extending
Abstract
Typolink Builder - Override or extend the
build
method() - Access the
$content
property directlyObject Renderer
Migration
For end users, generating links works the same way as before via:
Content
methodObject Renderer->typolink () Link
classFactory
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.