1/12/2024 0 Comments Drupal wiki plugin![]() The CacheDecorator implements a caching layer on top of another DiscoveryInterface. The best example of a decorator at use is the CacheDecorator. The decorator wraps around a DiscoveryInterface to provide additional functionality. Basically a discovery decorator is a wrapper around a discovery class. The plugin system also includes decorators. Loading the file in as php would mean that allocated memory was required until the request was finalised. The advantage to loading the file in as text is that once the file has been read, the memory is released. This allows loading each file in turn as text, instead of php, parsing the plugin information and registering the plugin. This is where chx came in and wrote a patch for Doctrine that utilises php's tokeniser. However this too required loading each file into memory. The next approach was to utilise Doctrine's annotation based discovery. However loading each file into memory in order to call the getInfo() method on the class has a memory overhead. This was analagous to test classes and returned name, description etc. Having them in the same place is obviously better DX.Įarly versions of the plugin system included a getInfo() method on each class. Previously you may have had an info hook in your module where the plugin was defined and then the class itself lived in a separate file. Why annotation based discovery is awesomeįirstly, annotation based discovery means the plugin metadata is defined with the actual plugin, in the same file, right there with the plugin class. This was committed as part of #1683644 Use Annotations for plugin discovery. This allows Drupal to discover plugins based on comments in the plugin's docblock. The fourth and perhaps most interesting mechanism is annotation based discovery. ![]() The third method is PersistentVariableDiscovery which is essentially a wrapper around config based plugins such as cache backends, basically anything you might have defined in settings.php. The second method is static discovery, which is useful for things like testing where the plugins are declared as a static property on the plugin manager class. This is analagous to a hook_info style hook such as hook_field_info or hook_entity_info. Anyone who's built any form of Drupal module would be familiar with one of the discovery mechanisms - hook discovery. For a great background see EclipseGC's presentation from MWDS or the handbook pages on .Īs indicated in Kris's presentation and the handbook pages, there are four forms of discovery. This is akin to ctools plugins but with much more flexibility. ![]() Drupal 8 features a brand-new plugin system. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |