interface SelectionPluginManagerInterface implements PluginManagerInterface (View source)

Defines an interface for the entity reference selection plugin manager.

Methods

mixed
getDefinition(string $plugin_id, bool $exception_on_invalid = TRUE)

Gets a specific plugin definition.

array
getDefinitions()

Gets the definition of all plugins for this type.

bool
hasDefinition(string $plugin_id)

Indicates if a specific plugin definition exists.

object
createInstance(string $plugin_id, array $configuration = [])

Creates a pre-configured instance of a plugin.

object|false
getInstance(array $options)

Gets a preconfigured instance of a plugin.

string
getPluginId(string $target_type, string $base_plugin_id)

Gets the plugin ID for a given target entity type and base plugin ID.

array
getSelectionGroups(string $entity_type_id)

Gets the selection plugins that can reference a specific entity type.

getSelectionHandler(FieldDefinitionInterface $field_definition, EntityInterface $entity = NULL)

Gets the selection handler for a given entity_reference field.

Details

mixed getDefinition(string $plugin_id, bool $exception_on_invalid = TRUE)

Gets a specific plugin definition.

Parameters

string $plugin_id

A plugin id.

bool $exception_on_invalid

(optional) If TRUE, an invalid plugin ID will throw an exception.

Return Value

mixed

A plugin definition, or NULL if the plugin ID is invalid and $exception_on_invalid is FALSE.

Exceptions

PluginNotFoundException

array getDefinitions()

Gets the definition of all plugins for this type.

Return Value

array

An array of plugin definitions (empty array if no definitions were found). Keys are plugin IDs.

See also

FilteredPluginManagerInterface::getFilteredDefinitions

bool hasDefinition(string $plugin_id)

Indicates if a specific plugin definition exists.

Parameters

string $plugin_id

A plugin ID.

Return Value

bool

TRUE if the definition exists, FALSE otherwise.

object createInstance(string $plugin_id, array $configuration = [])

Creates a pre-configured instance of a plugin.

Parameters

string $plugin_id

The ID of the plugin being instantiated.

array $configuration

An array of configuration relevant to the plugin instance.

Return Value

object

A fully configured plugin instance.

Exceptions

PluginException

object|false getInstance(array $options)

Gets a preconfigured instance of a plugin.

Parameters

array $options

An array of options that can be used to determine a suitable plugin to instantiate and how to configure it.

Return Value

object|false

A fully configured plugin instance. The interface of the plugin instance will depend on the plugin type. If no instance can be retrieved, FALSE will be returned.

string getPluginId(string $target_type, string $base_plugin_id)

Gets the plugin ID for a given target entity type and base plugin ID.

Parameters

string $target_type

The target entity type.

string $base_plugin_id

The base plugin ID (e.g. 'default' or 'views').

Return Value

string

The plugin ID.

array getSelectionGroups(string $entity_type_id)

Gets the selection plugins that can reference a specific entity type.

Parameters

string $entity_type_id

A Drupal entity type ID.

Return Value

array

An array of selection plugins grouped by selection group.

SelectionInterface getSelectionHandler(FieldDefinitionInterface $field_definition, EntityInterface $entity = NULL)

Gets the selection handler for a given entity_reference field.

Parameters

FieldDefinitionInterface $field_definition

The field definition for the operation.

EntityInterface $entity

(optional) The entity for the operation. Defaults to NULL.

Return Value

SelectionInterface

The selection plugin.