function ElementInfoManager::buildInfo

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

Builds up all element information.

Parameters

string $theme_name: The theme name.

Return value

array

1 call to ElementInfoManager::buildInfo()
ElementInfoManager::getInfo in core/lib/Drupal/Core/Render/ElementInfoManager.php
Retrieves the default properties for the defined element type.

File

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

Class

ElementInfoManager
Provides a plugin manager for element plugins.

Namespace

Drupal\Core\Render

Code

protected function buildInfo($theme_name) {
    // Get cached definitions.
    $cid = $this->getCid($theme_name);
    if ($cache = $this->cacheBackend
        ->get($cid)) {
        return $cache->data;
    }
    // Otherwise, rebuild and cache.
    $info = [];
    foreach ($this->getDefinitions() as $element_type => $definition) {
        $element = $this->createInstance($element_type);
        $element_info = $element->getInfo();
        // If this is element is to be used exclusively in a form, denote that it
        // will receive input, and assign the value callback.
        if ($element instanceof FormElementInterface) {
            $element_info['#input'] = TRUE;
            $element_info['#value_callback'] = [
                $definition['class'],
                'valueCallback',
            ];
        }
        $info[$element_type] = $element_info;
    }
    foreach ($info as $element_type => $element) {
        $info[$element_type]['#type'] = $element_type;
    }
    // Allow modules to alter the element type defaults.
    $this->moduleHandler
        ->alter('element_info', $info);
    $this->themeManager
        ->alter('element_info', $info);
    $this->cacheBackend
        ->set($cid, $info, Cache::PERMANENT, [
        'element_info_build',
    ]);
    return $info;
}

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