By baysaa on
Change record status:
Published (View all published change records)
Project:
Issue links:
Description:
Entity view builder plugins can now be defined using PHP 8.1+ attributes as an alternative to annotations. The existing annotation-based discovery continues to work.
What changed:
A new Drupal\pluggable_entity_view_builder\Attribute\EntityViewBuilder attribute class has been added, and EntityViewBuilderPluginManager has been updated to support attribute-based plugin discovery alongside the existing annotation-based discovery.
Plugins can now be defined with an attribute instead of an annotation:
#[EntityViewBuilder(
id: "node.article",
label: new TranslatableMarkup("Node Article"),
description: new TranslatableMarkup("Entity view builder for Article nodes."),
)]
class NodeArticle extends EntityViewBuilderPluginAbstract {How to update your code:
No changes are required. Existing annotation-based plugins continue to work. You may optionally migrate your plugin definitions to use the new attribute syntax.