- Issue created by @larowlan
- π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Dupe of β¨ Use constants for plugin IDs Active
Throughout core we make heavy use of plugins.
When initiating plugins we typically pass the plugin ID to a plugin manager.
e.g.
\Drupal::service('plugin.manager.block')->createInstance('system_breadcrumb_block')
Each of these Plugin IDs have special meaning, they're not just a string.
Detecting usages of these IDs vs a string requires grepping the code and eliminating false positives.
Misspelling the plugin ID can lead to plugin not found exceptions.
Now that we have attributes for plugin discovery, we can replace hard-coded strings with constants.
Attributes are smart enough to be able to detect that self::PLUGIN_ID
refers to the object with the attribute.
public const string PLUGIN_ID = '{the plugin id here}
self::PLUGIN_ID
PLUGIN_ID
, use ENTITY_TYPE_ID
insteadAll of the above
Active
11.0 π₯
plugin system
Enhances developer experience.
Dupe of β¨ Use constants for plugin IDs Active