class ConstraintFactory extends ContainerFactory (View source)

Constraint plugin factory.

Symfony Constraint plugins are created as Drupal plugins, but the default plugin constructor is not compatible.

Properties

protected DiscoveryInterface $discovery

The object that retrieves the definitions of the plugins that this factory instantiates.

from  DefaultFactory
protected string|null $interface

Defines an interface each plugin should implement.

from  DefaultFactory

Methods

__construct(DiscoveryInterface $discovery, string|null $plugin_interface = NULL)

Constructs a Drupal\Component\Plugin\Factory\DefaultFactory object.

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

Creates a pre-configured instance of a plugin.

static string
getPluginClass(string $plugin_id, PluginDefinitionInterface|array $plugin_definition = NULL, string $required_interface = NULL)

Finds the class relevant for a given plugin.

Details

__construct(DiscoveryInterface $discovery, string|null $plugin_interface = NULL)

Constructs a Drupal\Component\Plugin\Factory\DefaultFactory object.

Parameters

DiscoveryInterface $discovery

The plugin discovery.

string|null $plugin_interface

(optional) The interface each plugin should implement.

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

static string getPluginClass(string $plugin_id, PluginDefinitionInterface|array $plugin_definition = NULL, string $required_interface = NULL)

Finds the class relevant for a given plugin.

Parameters

string $plugin_id

The id of a plugin.

PluginDefinitionInterface|array $plugin_definition

The plugin definition associated with the plugin ID.

string $required_interface

(optional) The required plugin interface.

Return Value

string

The appropriate class name.

Exceptions

PluginException