ElementInfoManager::buildInfo

protected ElementInfoManager::buildInfo($theme_name)

Builds up all element information.

Parameters

string $theme_name: The theme name.

Return value

array

File

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

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'] = array($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;
}
doc_Drupal
2016-10-29 09:04:02
Comments
Leave a Comment

Please login to continue.