function ElementInfoManager::getInfo

Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Render/ElementInfoManager.php \Drupal\Core\Render\ElementInfoManager::getInfo()
  2. 10 core/lib/Drupal/Core/Render/ElementInfoManager.php \Drupal\Core\Render\ElementInfoManager::getInfo()
  3. 11.x core/lib/Drupal/Core/Render/ElementInfoManager.php \Drupal\Core\Render\ElementInfoManager::getInfo()

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).

Overrides ElementInfoManagerInterface::getInfo

1 call to ElementInfoManager::getInfo()
ElementInfoManager::getInfoProperty in core/lib/Drupal/Core/Render/ElementInfoManager.php
Retrieves a single property for the defined element type.

File

core/lib/Drupal/Core/Render/ElementInfoManager.php, line 74

Class

ElementInfoManager
Provides a plugin manager for element plugins.

Namespace

Drupal\Core\Render

Code

public function getInfo($type) {
    $theme_name = $this->themeManager
        ->getActiveTheme()
        ->getName();
    if (!isset($this->elementInfo[$theme_name])) {
        $this->elementInfo[$theme_name] = $this->buildInfo($theme_name);
    }
    $info = $this->elementInfo[$theme_name][$type] ?? [];
    $info['#defaults_loaded'] = TRUE;
    return $info;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.