July 2017
Intermediate to advanced
456 pages
11h 32m
English
An annotation is metadata that can be added to a file, class, function, or variable. These can be used to add information describing plugins without having to write a separate function. In Drupal 7, in order to expose a block, you needed to implement at least two hooks: hook_block_info to describe the block, give it a label, a machine name, describe caching, and so on; and then at least hook_block_view to render it. The same file that contains the plugin implementation also contains the metadata about it. It's encoded as a PHP docblock on the class itself. You can see that above the class declaration in our TestBlock.php file.
/*** Provides a 'TestBlock' block.** @Block(* id = "test_block",* admin_label = @Translation("Test block"), ...Read now
Unlock full access