ListElement::getGroupTitle

protected ListElement::getGroupTitle(DataDefinitionInterface $definition, array $group_build)

Returns the title for the 'details' element of a group of schema elements.

For some configuration elements the same element structure can be repeated multiple times (for example views displays, filters, etc.). Thus, we try to find a more usable title for the details summary. First check if there is an element which is called title or label and use its value. Then check if there is an element which contains these words and use those. Fall back to the generic definition label if no such element is found.

Parameters

\Drupal\Core\TypedData\DataDefinitionInterface $definition: The definition of the schema element.

array $group_build: The renderable array for the group of schema elements.

Return value

string The title for the group of schema elements.

File

core/modules/config_translation/src/FormElement/ListElement.php, line 112

Class

ListElement
Defines the list element for the configuration translation interface.

Namespace

Drupal\config_translation\FormElement

Code

protected function getGroupTitle(DataDefinitionInterface $definition, array $group_build) {
  $title = '';
  if (isset($group_build['title']['source'])) {
    $title = $group_build['title']['source']['#markup'];
  }
  elseif (isset($group_build['label']['source'])) {
    $title = $group_build['label']['source']['#markup'];
  }
  else {
    foreach (array_keys($group_build) as $title_key) {
      if (isset($group_build[$title_key]['source']) && (strpos($title_key, 'title') !== FALSE || strpos($title_key, 'label') !== FALSE)) {
        $title = $group_build[$title_key]['source']['#markup'];
        break;
      }
    }
  }
  return (!empty($title) ? (strip_tags($title) . ' ') : '') . $this->t($definition['label']);
}
doc_Drupal
2016-10-29 09:23:31
Comments
Leave a Comment

Please login to continue.