Deprecation: #106405 - AbstractTypolinkBuilder->build 

See forge#106405

Description 

The build() method in \TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder has been deprecated in favor of the new TypolinkBuilderInterface.

When creating custom TypolinkBuilder classes, the traditional approach of:

  1. Extending AbstractTypolinkBuilder
  2. Implementing the build() method
  3. Receiving dependencies via constructor

This approach is now deprecated. The new recommended approach is to implement the TypolinkBuilderInterface.

The ContentObjectRenderer property in AbstractTypolinkBuilder is also deprecated and will be removed in TYPO3 v15.0. The ContentObjectRenderer should be accessed via the ServerRequestInterface object instead.

Impact 

Extension authors who have created custom TypolinkBuilder classes extending from AbstractTypolinkBuilder 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 $contentObjectRenderer property
  • The old constructor approach is used for dependency handling

Affected installations 

TYPO3 installations with extensions that:

  • Create custom TypolinkBuilder classes extending AbstractTypolinkBuilder
  • Override or extend the build() method
  • Access the $contentObjectRenderer property directly

Migration 

For end users, generating links works the same way as before via:

  • ContentObjectRenderer->typolink() method
  • LinkFactory class

No deprecation warnings will be triggered when using the public APIs.

For extension developers with custom TypolinkBuilder classes:

  1. Implement the new interface:
Recommended migration approach
// 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
    }
}
Copied!
  1. Use dependency injection for required services instead of accessing them via global state or constructor arguments.
  2. Access ContentObjectRenderer via the request object rather than the deprecated property.

Note: All implementations of TypolinkBuilderInterface 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 buildLink() method.