Plugin
Provides various utility helpers for plugins.
- Full name:
\Drupal\helper\Plugin
Constants
| Constant | Visibility | Type | Value |
|---|---|---|---|
KNOWN_LABEL_KEYS |
protected | ['block' => 'admin_label', 'filter' => 'title'] |
Methods
getManager
Get the plugin manager.
public static getManager(string $plugin_type): \Drupal\Component\Plugin\PluginManagerInterface
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$plugin_type |
string | |
| The plugin type. |
Return Value:
The plugin manager.
invoke
Call a plugin callback and return its result.
public static invoke(string $plugin_type, string $plugin_id, array $configuration, string $callback, mixed $args): mixed
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$plugin_type |
string | |
| The plugin type. | ||
$plugin_id |
string | |
| The plugin ID. | ||
$configuration |
array | |
| The plugin configuration. | ||
$callback |
string | |
| The method to call on the plugin class. | ||
$args |
mixed | |
| The arguments to pass to the plugin callback. |
Return Value:
The return value from the plugin method.
getOptions
Get an option list of allowed plugins.
public static getOptions(string $plugin_type, array|string|null $definitions = null, array $options = []): array
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$plugin_type |
string | |
| The plugin type. | ||
$definitions |
array|string|null | |
| 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. | ||
$options |
array | |
| 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 Value:
The list of plugins ready for a form element #options.