annotation docs should document how to set data types other than strings

Created on 26 January 2023, over 1 year ago
Updated 30 October 2023, 8 months ago

API page: https://api.drupal.org/api/drupal/core%21core.api.php/group/annotation/10

The documentation for annotations shows examples of how to set string values, but is missing examples for other data types.

For example, seen in the ChangedItem class, we have:

 *   label = @Translation("Last changed"),
 *   description = @Translation("An entity field containing a UNIX timestamp of when the entity has been last updated."),
 *   no_ui = TRUE,
 *   default_widget = "datetime_timestamp",
 *   default_formatter = "timestamp",
 *   list_class = "\Drupal\Core\Field\ChangedFieldItemList"

and in CommentItem:

 *   cardinality = 1,

These show how to define:

- translated string
- boolean
- class (we should in particular say that classes need the initial slash)
- int

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Documentation 

Last updated about 2 hours ago

No maintainer
Created by

🇬🇧United Kingdom joachim

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024