Same name and namespace in other branches
- 8.9.x core/core.api.php \annotation
- 9 core/core.api.php \annotation
Annotations for class discovery and metadata description.
The Drupal plugin system has a set of reusable components that developers can use, override, and extend in their modules. Most of the plugins use annotations, which let classes register themselves as plugins and describe their metadata. (Annotations can also be used for other purposes, though at the moment, Drupal only uses them for the plugin system.)
To annotate a class as a plugin, add code similar to the following to the end of the documentation block immediately preceding the class declaration:
* @ContentEntityType(
* id = "comment",
* label = @Translation("Comment"),
* ...
* base_table = "comment"
* )
Note that you must use double quotes; single quotes will not work in annotations.
Some annotation types, which extend the "@ PluginID" annotation class, have only a single 'id' key in their annotation. For these, it is possible to use a shorthand annotation. For example:
* @ViewsArea("entity")
in place of
* @ViewsArea(
* id = "entity"
*)
The available annotation classes are listed in this topic, and can be identified when you are looking at the Drupal source code by having "@ Annotation" in their documentation blocks (without the space after @). To find examples of annotation for a particular annotation class, such as EntityType, look for class files that have an @ annotation section using the annotation class.
See also
Annotation for translatable text
Annotation for context definition
File
- core/
core.api.php, line 1849 - Documentation landing page and topics, plus core library hooks.
Classes
Name | Location | Description |
---|---|---|
Entity |
core/ |
|
Entity |
core/ |
This class is a near-copy of tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Entity.php, which is part of the Doctrine project: <http://www.doctrine-project.org>. It was copied from version 1.2.7. |
AnnotationWithVarType |
core/ |
Plugin annotation @Target("ALL"); |
AnnotationWithTargetSyntaxError |
core/ |
Plugin annotation @Target(@) |
AnnotationWithRequiredAttributesWithoutContructor |
core/ |
Plugin annotation @Target("ALL"); |
AnnotationWithRequiredAttributes |
core/ |
Plugin annotation @Target("ALL") @Attributes({ @Attribute("value", required = true , type = "string"), @Attribute("annot", required = true , type =… |
AnnotationWithConstants |
core/ |
Plugin annotation @Target("ALL"); |
AnnotationWithAttributes |
core/ |
Plugin annotation @Target("ALL") @Attributes({ @Attribute("mixed", type = "mixed"), @Attribute("boolean", type = "boolean"), @Attribute("bool", type = "bool"), @Attribute("float", … |
AnnotationTargetPropertyMethod |
core/ |
Plugin annotation @Target({ "METHOD", "PROPERTY" }) |
AnnotationTargetClass |
core/ |
Plugin annotation @Target("CLASS"); |
AnnotationTargetAnnotation |
core/ |
Plugin annotation @Target({ "ANNOTATION" }) |
AnnotationTargetAll |
core/ |
Plugin annotation @Target("ALL"); |
AnnotationEnumLiteralInvalid |
core/ |
Plugin annotation @Target("ALL"); |
AnnotationEnumLiteral |
core/ |
Plugin annotation @Target("ALL"); |
AnnotationEnumInvalid |
core/ |
Plugin annotation @Target("ALL"); |
AnnotationEnum |
core/ |
Plugin annotation @Target("ALL"); |
Version |
core/ |
Plugin annotation @Target("PROPERTY"); |
Template |
core/ |
|
Secure |
core/ |
|
Route |
core/ |
|
Autoload |
core/ |
|
AnnotWithDefaultValue |
core/ |
|
SettingsAnnotation |
core/ |
|
SomeAnnotationClassNameWithoutConstructor |
core/ |
|
SomeAnnotationWithConstructorWithoutParams |
core/ |
|
SomeAnnotationClassNameWithoutConstructorAndProperties |
core/ |
|
AnnotationWithInvalidTargetDeclaration |
core/ |
Plugin annotation @Target("Foo"); |
AnnotationWithTargetEmpty |
core/ |
@Target |
AnnotationExtendsAnnotationTargetAll |
core/ |
|
Name |
core/ |
|
Marker |
core/ |
|
CustomPlugin |
core/ |
Custom plugin annotation. |
CustomPlugin2 |
core/ |
Custom plugin annotation. |
WorkflowType |
core/ |
Defines a Workflow type annotation object. |
ViewsWizard |
core/ |
Defines a Plugin annotation object for views wizard plugins. |
ViewsStyle |
core/ |
Defines a Plugin annotation object for views style plugins. |
ViewsSort |
core/ |
Defines a Plugin annotation object for views sort handlers. |
ViewsRow |
core/ |
Defines a Plugin annotation object for views row plugins. |
ViewsRelationship |
core/ |
Defines a Plugin annotation object for views relationship handlers. |
ViewsQuery |
core/ |
Defines a Plugin annotation object for views query plugins. |
ViewsPager |
core/ |
Defines a Plugin annotation object for views pager plugins. |
ViewsJoin |
core/ |
Defines a Plugin annotation object for views join plugins. |
ViewsFilter |
core/ |
Defines a Plugin annotation object for views filter handlers. |
ViewsField |
core/ |
Defines a Plugin annotation object for views field handlers. |
ViewsExposedForm |
core/ |
Defines a Plugin annotation object for views exposed form plugins. |
ViewsDisplayExtender |
core/ |
Defines a Plugin annotation object for views display extender plugins. |
ViewsDisplay |
core/ |
Defines a Plugin annotation object for views display plugins. |
ViewsCache |
core/ |
Defines a Plugin annotation object for views cache plugins. |
ViewsArgumentValidator |
core/ |
Defines a Plugin annotation object for views argument validator plugins. |
ViewsArgumentDefault |
core/ |
Defines a Plugin annotation object for views argument default plugins. |
ViewsArgument |
core/ |
Defines a Plugin annotation object for views argument handlers. |
ViewsArea |
core/ |
Defines a Plugin annotation object for views area handlers. |
ViewsAccess |
core/ |
Defines a Plugin annotation object for views access plugins. |
Tip |
core/ |
Defines a tour item annotation object. |
PluginExtended |
core/ |
Defines a test annotation that extends an annotation in another namespace. |
PluginExample |
core/ |
Defines a custom Plugin annotation. |
SearchPlugin |
core/ |
Defines a SearchPlugin type annotation object. |
RestResource |
core/ |
Defines a REST resource annotation object. |
MigrateField |
core/ |
Defines a field plugin annotation object. |
MigrateSource |
core/ |
Defines a migration source plugin annotation object. |
MigrateProcessPlugin |
core/ |
Defines a migration process plugin annotation object. |
MigrateDestination |
core/ |
Defines a migration destination plugin annotation object. |
MediaSource |
core/ |
Defines a media source plugin annotation object. |
SectionStorage |
core/ |
Defines a Section Storage type annotation object. |
LanguageNegotiation |
core/ |
Defines a language negotiation annotation object. |
ImageEffect |
core/ |
Defines an image effect annotation object. |
HelpSection |
core/ |
Defines a Plugin annotation object for help page section plugins. |
Filter |
core/ |
Defines a filter annotation object. |
Editor |
core/ |
Defines an Editor annotation object. |
DrupalAspectsOfCKEditor5Plugin |
core/ |
Defines the "Drupal aspects of a CKEditor5Plugin" annotation object. |
CKEditor5Plugin |
core/ |
Defines a CKEditor5Plugin annotation object. |
CKEditor5AspectsOfCKEditor5Plugin |
core/ |
Defines the "CKEditor 5 aspects of a CKEditor5Plugin" annotation object. |
CKEditor4To5Upgrade |
core/ |
Defines a CKEditor4To5Upgrade annotation object. |
Constraint |
core/ |
Defines a validation constraint annotation object. |
DataType |
core/ |
Defines a data type annotation object. |
RenderElement |
core/ |
Defines a render element plugin annotation object. |
FormElement |
core/ |
Defines a form element plugin annotation object. |
Layout |
core/ |
Defines a Layout annotation object. |
ImageToolkitOperation |
core/ |
Defines a Plugin annotation object for the image toolkit operation plugin. |
ImageToolkit |
core/ |
Defines a Plugin annotation object for the image toolkit plugin. |
FieldWidget |
core/ |
Defines a FieldWidget annotation object. |
FieldType |
core/ |
Defines a FieldType annotation object. |
FieldFormatter |
core/ |
Defines a FieldFormatter annotation object. |
EntityType |
core/ |
Defines an Entity type annotation object. |
EntityReferenceSelection |
core/ |
Defines an EntityReferenceSelection plugin annotation object. |
ContentEntityType |
core/ |
Defines a content entity type annotation object. |
ConfigEntityType |
core/ |
Defines a config entity type annotation object. |
PageDisplayVariant |
core/ |
Defines a page display variant annotation object. |
DisplayVariant |
core/ |
Defines a display variant annotation object. |
Condition |
core/ |
Defines a condition plugin annotation object. |
Block |
core/ |
Defines a Block annotation object. |
Archiver |
core/ |
Defines an archiver annotation object. |
Translation |
core/ |
Defines a translatable annotation object. |
QueueWorker |
core/ |
Declare a worker class for processing a queue item. |
PluralTranslation |
core/ |
Defines an annotation object for strings that require plural forms. |
core/ |
Defines a Mail annotation object. | |
ContextDefinition |
core/ |
Defines a context definition annotation object. |
Action |
core/ |
Defines an Action annotation object. |
PluginID |
core/ |
Defines a Plugin annotation object that just contains an ID. |
Plugin |
core/ |
Defines a Plugin annotation object. |