Feature: #110287 - Register meta tag managers as tagged services 

See forge#110287

Description 

Meta tag managers, used to manage and render the <meta> tags of a page, are now registered as tagged services via dependency injection instead of the previous programmatic registration through \TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry->registerManager() in ext_localconf.php.

A meta tag manager class implementing \TYPO3\CMS\Core\MetaTag\MetaTagManagerInterface (usually by extending \TYPO3\CMS\Core\MetaTag\AbstractMetaTagManager ) is registered by adding the new PHP attribute \TYPO3\CMS\Core\Attribute\AsMetaTagManager to the class:

EXT:my_extension/Classes/MetaTag/MyMetaTagManager.php
use TYPO3\CMS\Core\Attribute\AsMetaTagManager;
use TYPO3\CMS\Core\MetaTag\AbstractMetaTagManager;

#[AsMetaTagManager(identifier: 'my-manager')]
final class MyMetaTagManager extends AbstractMetaTagManager
{
    // ...
}
Copied!

The manager order is defined at registration time via the optional before and after attribute arguments, referencing the identifiers of other managers. A manager without constraints is ordered before the generic manager shipped with TYPO3 Core, which handles every property and therefore always comes last — this matches the previous default of registerManager() .

#[AsMetaTagManager(identifier: 'my-manager', before: ['opengraph'], after: ['html5'])]
Copied!

Alternatively, the service tag metatag.manager can be used directly in Configuration/Services.yaml, with before and after given as comma-separated lists:

EXT:my_extension/Configuration/Services.yaml
MyVendor\MyExtension\MetaTag\MyMetaTagManager:
  tags:
    - name: metatag.manager
      identifier: 'my-manager'
Copied!

Impact 

Registering meta tag managers as tagged services has the following benefits over the previous programmatic registration:

  • The registration and the resolution of the before / after ordering constraints happen once at container compile time instead of executing registration code from ext_localconf.php and sorting the managers on every request.
  • Meta tag managers are proper services now and can use dependency injection in their constructor.
  • The registration is validated at container compile time: a service tagged as metatag.manager that does not implement MetaTagManagerInterface , or is missing the identifier tag attribute, fails the container build with a speaking exception.

Registration in ext_localconf.php via MetaTagManagerRegistry->registerManager() is not evaluated anymore, see Breaking: #110287 - Meta tag manager registration and interface changed for the upgrade path.