- Drupal 8 Module Development
- Daniel Sipos
- 337字
- 2021-07-02 12:22:35
Plugins
Plugins are new to Drupal 8 and are an elegant solution to an important problem— encapsulating functionality. Right off the bat, you should not confuse them with things such as the WordPress plugins, which are more akin to Drupal modules. Instead, you should think of plugins as components of reusable code that can be used and managed by a central system. Typically, they are used when a system handles a task in a certain way (plugin A) but allows other modules to provide different ways to handle that task (plugin B or C).
You can also look at plugins as being opposite to entities: not used for data storage, but for functionality. Instead of creating a type of data that gets stored, you create a type of functionality that is used. The two usually work hand in hand, especially when it comes to manipulating the data in different ways.
An important aspect of how they work is their discoverability. Most plugin types (but definitely not all) are discovered via something called Annotations. Annotations are a form of DocBlock comments, borrowed from the Doctrine library (http://docs.doctrine-project.org/projects/doctrine-common/en/latest/reference/annotations.html), by which we can describe classes, methods, and even properties with certain metadata. This metadata is then read to determine what that item is without the need for instantiating the class. In Drupal 8, we use annotations only at a class level to denote that it is a plugin implementation with certain characteristics. That is how most plugins are discovered in Drupal 8.
The second most common discoverability method for plugins is via a YAML file, and a popular example of those are menu links (as we will see later in the book). However, for now, you should know that plugins are very widely used, and we will create quite a few plugins in this book.
Plugins are a great new extension point for developers to add their own functionality and are a critical subsystem in Drupal 8. Every Drupal 8 developer needs to be comfortable with the plugin system.
- Mastering Entity Framework Core 2.0
- Java高手真經(jīng)(高級編程卷):Java Web高級開發(fā)技術(shù)
- Visual Basic程序設(shè)計(第3版):學習指導與練習
- R語言數(shù)據(jù)可視化實戰(zhàn)
- Web全棧工程師的自我修養(yǎng)
- 小程序開發(fā)原理與實戰(zhàn)
- Python算法指南:程序員經(jīng)典算法分析與實現(xiàn)
- 響應(yīng)式架構(gòu):消息模式Actor實現(xiàn)與Scala、Akka應(yīng)用集成
- Deep Learning with R Cookbook
- OpenCV 3計算機視覺:Python語言實現(xiàn)(原書第2版)
- Photoshop智能手機APP界面設(shè)計
- Python面試通關(guān)寶典
- Elastix Unified Communications Server Cookbook
- MySQL數(shù)據(jù)庫教程(視頻指導版)
- Java程序設(shè)計基礎(chǔ)教程