官术网_书友最值得收藏!

Plugins

Plugins are new to Drupal in its latest version and are an elegant solution to an important problem--the encapsulating and reusing functionalities. 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. They are typically used to allow others to contribute their own distinct functionality within your own system. Looking at it from the other direction, Drupal core, for example, handles many things in a certain way, but allows you to provide your own plugins to handle those things in a different way.

An interesting way of looking at plugins is also as being opposite to entities, not 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.

Plugins are a great new extension point for developers to add their own functionality and are a critical subsystem for Drupal 8 developers to know. 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 these 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.

主站蜘蛛池模板: 滕州市| 齐河县| 易门县| 泸溪县| 崇阳县| 色达县| 平武县| 腾冲县| 沈丘县| 新化县| 保定市| 太仆寺旗| 武宁县| 抚远县| 阿拉善右旗| 潜山县| 蒙城县| 定边县| 德昌县| 含山县| 探索| 台南市| 庆阳市| 普兰县| 新干县| 商城县| 赤水市| 庆云县| 三江| 丰镇市| 溆浦县| 类乌齐县| 黄骅市| 无棣县| 济南市| 凤凰县| 永仁县| 邯郸市| 绥中县| 南汇区| 商洛市|