Drupal\helper\Plugin
Provides various utility helpers for plugins.
Methods
| Name | Description |
|---|---|
| getManager | Get the plugin manager. |
| getOptions | Get an option list of allowed plugins. |
| invoke | Call a plugin callback and return its result. |
Plugin::getManager
Description
public static getManager (string $plugin_type)
Get the plugin manager.
Parameters
(string) $plugin_type:
The plugin type.
Return Values
\Drupal\Component\Plugin\PluginManagerInterface
The plugin manager.
Plugin::getOptions
Description
public static getOptions (string $plugin_type, array|string|null $definitions, array $options)
Get an option list of allowed plugins.
Parameters
(string) $plugin_type:
The plugin type.(array|string|null) $definitions:
The definitions to convert to options. If provided as a string, it will
be passed to getFilteredDefinitions() as the first $consumer argument.
If not provided they will be fetched from the plugin manager.(array) $options:
An optional array of additional options:- label key (string): What key to use in the definition as the label.
- fallback (boolean): If the fallback plugin should be included.
- contexts (array): Parameter to pass to getFilteredDefinitions().
- extra (array): Parameter to pass to getFilteredDefinitions().
Return Values
array
The list of plugins ready for a form element #options.
Plugin::invoke
Description
public static invoke (string $plugin_type, string $plugin_id, array $configuration, string $callback, mixed $args)
Call a plugin callback and return its result.
Parameters
(string) $plugin_type:
The plugin type.(string) $plugin_id:
The plugin ID.(array) $configuration:
The plugin configuration.(string) $callback:
The method to call on the plugin class.(mixed) $args:
The arguments to pass to the plugin callback.
Return Values
mixed
The return value from the plugin method.