Submitted by admin on

Annotations are only used by the Plugin system in Drupal 8

Annotations  contain metadata about the function or class.

Annotations are written as PHP code comments above a class or function .

How Drupal understand the annotations

Block manager scans files looking for @Block annotation tag to find block instances

Annotation parser

Annotations are read and parsed at runtime by an annotation engine. Drupal 8 uses the Doctrine annotation parser, which turns it into an object that PHP can use.

Drupal Annotation Syntax

 

Drupal’s Annotation syntax is taken from Doctrines (but it is not exactly the same).

Annotations comprise of nested key value pairs and support nesting.