Annotations
Same name in other branches
- 9 core/core.api.php \annotation
- 10 core/core.api.php \annotation
- 11.x 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 1841
Classes
Title Sort descending | Deprecated | File name | Summary |
---|---|---|---|
Action | core/ |
Defines an Action annotation object. | |
AggregatorFetcher | core/ |
Defines a Plugin annotation object for aggregator fetcher plugins. | |
AggregatorParser | core/ |
Defines a Plugin annotation object for aggregator parser plugins. | |
AggregatorProcessor | core/ |
Defines a Plugin annotation object for aggregator processor plugins. | |
AnnotationEnum | core/ |
Plugin annotation @Target("ALL"); |
|
AnnotationEnumInvalid | core/ |
Plugin annotation @Target("ALL"); |
|
AnnotationEnumLiteral | core/ |
Plugin annotation @Target("ALL"); |
|
AnnotationEnumLiteralInvalid | core/ |
Plugin annotation @Target("ALL"); |
|
AnnotationExtendsAnnotationTargetAll | core/ |
||
AnnotationTargetAll | core/ |
Plugin annotation @Target("ALL"); |
|
AnnotationTargetAnnotation | core/ |
Plugin annotation @Target({ "ANNOTATION" }) |
|
AnnotationTargetClass | core/ |
Plugin annotation @Target("CLASS"); |
|
AnnotationTargetPropertyMethod | core/ |
Plugin annotation @Target({ "METHOD", "PROPERTY" }) |
|
AnnotationWithAttributes | core/ |
Plugin annotation @Target("ALL") @Attributes({ @Attribute("mixed", type = "mixed"), @Attribute("boolean", type = "boolean"), @Attribute("bool", type = "bool"), @Attribute("float", … |
|
AnnotationWithConstants | core/ |
Plugin annotation @Target("ALL"); |
|
AnnotationWithInvalidTargetDeclaration | core/ |
Plugin annotation @Target("Foo"); |
|
AnnotationWithRequiredAttributes | core/ |
Plugin annotation @Target("ALL") @Attributes({ @Attribute("value", required = true , type = "string"), @Attribute("annot", required = true , type =… |
|
AnnotationWithRequiredAttributesWithoutContructor | core/ |
Plugin annotation @Target("ALL"); |
|
AnnotationWithTargetEmpty | core/ |
@Target | |
AnnotationWithTargetSyntaxError | core/ |
Plugin annotation @Target(@) |
|
AnnotationWithVarType | core/ |
Plugin annotation @Target("ALL"); |
|
AnnotWithDefaultValue | core/ |
||
Archiver | core/ |
Defines an archiver annotation object. | |
Autoload | core/ |
||
Block | core/ |
Defines a Block annotation object. | |
CKEditorPlugin | core/ |
Defines a CKEditorPlugin annotation object. | |
Condition | core/ |
Defines a condition plugin annotation object. | |
ConfigEntityType | core/ |
Defines a config entity type annotation object. | |
Constraint | core/ |
Defines a validation constraint annotation object. | |
ContentEntityType | core/ |
Defines a content entity type annotation object. | |
ContextDefinition | core/ |
Defines a context definition annotation object. | |
CustomPlugin | core/ |
Custom plugin annotation. | |
CustomPlugin2 | core/ |
Custom plugin annotation. | |
DataType | core/ |
Defines a data type annotation object. | |
DisplayVariant | core/ |
Defines a display variant annotation object. | |
Editor | core/ |
Defines an Editor annotation object. | |
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. |
|
EntityReferenceSelection | core/ |
Defines an EntityReferenceSelection plugin annotation object. | |
EntityType | core/ |
Defines an Entity type annotation object. | |
FieldFormatter | core/ |
Defines a FieldFormatter annotation object. | |
FieldType | core/ |
Defines a FieldType annotation object. | |
FieldWidget | core/ |
Defines a FieldWidget annotation object. | |
Filter | core/ |
Defines an filter annotation object. | |
FormElement | core/ |
Defines a form element plugin annotation object. | |
HelpSection | core/ |
Defines a Plugin annotation object for help page section plugins. | |
ImageEffect | core/ |
Defines an image effect annotation object. | |
ImageToolkit | core/ |
Defines a Plugin annotation object for the image toolkit plugin. | |
ImageToolkitOperation | core/ |
Defines a Plugin annotation object for the image toolkit operation plugin. | |
InPlaceEditor | core/ |
Defines an InPlaceEditor annotation object. | |
LanguageNegotiation | core/ |
Defines a language negotiation annotation object. | |
Layout | core/ |
Defines a Layout annotation object. | |
core/ |
Defines a Mail annotation object. | ||
Marker | core/ |
||
MediaSource | core/ |
Defines a media source plugin annotation object. | |
MigrateCckField | Deprecated | core/ |
Deprecated: Defines a cckfield plugin annotation object. |
MigrateDestination | core/ |
Defines a migration destination plugin annotation object. | |
MigrateField | core/ |
Defines a field plugin annotation object. | |
MigrateProcessPlugin | core/ |
Defines a migration process plugin annotation object. | |
MigrateSource | core/ |
Defines a migration source plugin annotation object. | |
Name | core/ |
||
PageDisplayVariant | core/ |
Defines a page display variant annotation object. | |
Plugin | core/ |
Defines a Plugin annotation object. | |
PluginExample | core/ |
Defines a custom Plugin annotation. | |
PluginExtended | core/ |
Defines a test annotation that extends an annotation in another namespace. | |
PluginID | core/ |
Defines a Plugin annotation object that just contains an ID. | |
PluralTranslation | core/ |
Defines an annotation object for strings that require plural forms. | |
QueueWorker | core/ |
Declare a worker class for processing a queue item. | |
RenderElement | core/ |
Defines a render element plugin annotation object. | |
RestResource | core/ |
Defines a REST resource annotation object. | |
Route | core/ |
||
SearchPlugin | core/ |
Defines a SearchPlugin type annotation object. | |
SectionStorage | core/ |
Defines a Section Storage type annotation object. | |
Secure | core/ |
||
SettingsAnnotation | core/ |
||
SomeAnnotationClassNameWithoutConstructor | core/ |
||
SomeAnnotationClassNameWithoutConstructorAndProperties | core/ |
||
SomeAnnotationWithConstructorWithoutParams | core/ |
||
Template | core/ |
||
Tip | core/ |
Defines a tour item annotation object. | |
Translation | core/ |
Defines a translatable annotation object. | |
Version | core/ |
Plugin annotation @Target("PROPERTY"); |
|
ViewsAccess | core/ |
Defines a Plugin annotation object for views access plugins. | |
ViewsArea | core/ |
Defines a Plugin annotation object for views area handlers. | |
ViewsArgument | core/ |
Defines a Plugin annotation object for views argument handlers. | |
ViewsArgumentDefault | core/ |
Defines a Plugin annotation object for views argument default plugins. | |
ViewsArgumentValidator | core/ |
Defines a Plugin annotation object for views argument validator plugins. | |
ViewsCache | core/ |
Defines a Plugin annotation object for views cache plugins. | |
ViewsDisplay | core/ |
Defines a Plugin annotation object for views display plugins. | |
ViewsDisplayExtender | core/ |
Defines a Plugin annotation object for views display extender plugins. | |
ViewsExposedForm | core/ |
Defines a Plugin annotation object for views exposed form plugins. | |
ViewsField | core/ |
Defines a Plugin annotation object for views field handlers. | |
ViewsFilter | core/ |
Defines a Plugin annotation object for views filter handlers. | |
ViewsJoin | core/ |
Defines a Plugin annotation object for views join plugins. | |
ViewsPager | core/ |
Defines a Plugin annotation object for views pager plugins. | |
ViewsQuery | core/ |
Defines a Plugin annotation object for views query plugins. | |
ViewsRelationship | core/ |
Defines a Plugin annotation object for views relationship handlers. | |
ViewsRow | core/ |
Defines a Plugin annotation object for views row plugins. | |
ViewsSort | core/ |
Defines a Plugin annotation object for views sort handlers. | |
ViewsStyle | core/ |
Defines a Plugin annotation object for views style plugins. | |
ViewsWizard | core/ |
Defines a Plugin annotation object for views wizard plugins. | |
WorkflowType | core/ |
Defines an Workflow type annotation object. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.