interface ElementInfoManagerInterface implements DiscoveryInterface (View source)

Collects available render array element types.

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.

array
getInfo(string $type)

Retrieves the default properties for the defined element type.

mixed
getInfoProperty(string $type, string $property_name, $default = NULL)

Retrieves a single property for the defined element type.

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.

array getInfo(string $type)

Retrieves the default properties for the defined element type.

Each of the element types defined by this hook is assumed to have a matching theme hook, which should be registered with hook_theme() as normal.

For more information about custom element types see the explanation at https://www.drupal.org/node/169815.

Parameters

string $type

The machine name of an element type plugin.

Return Value

array

An associative array describing the element types being defined. The array contains a sub-array for each element type, with the machine-readable type name as the key. Each sub-array has a number of possible attributes:

  • input: boolean indicating whether or not this element carries a value

    (even if it's hidden).

  • process: array of callback functions taking $element, $form_state,

    and $complete_form.

  • after_build: array of callables taking $element and $form_state.

  • validate: array of callback functions taking $form and $form_state.

  • element_validate: array of callback functions taking $element and

    $form_state.

  • pre_render: array of callables taking $element.

  • post_render: array of callables taking $children and $element.

  • submit: array of callback functions taking $form and $form_state.

  • title_display: optional string indicating if and how #title should be

    displayed (see form-element.html.twig).

See also

ElementInterface
ElementInterface::getInfo

mixed getInfoProperty(string $type, string $property_name, $default = NULL)

Retrieves a single property for the defined element type.

Parameters

string $type

An element type as defined by an element plugin.

string $property_name

The property within the element type that should be returned.

$default

(Optional) The value to return if the element type does not specify a value for the property. Defaults to NULL.

Return Value

mixed

The property value of the defined element type. Or the provided default value, which can be NULL.