function DisplayPluginBase::getFieldLabels

Same name and namespace in other branches
  1. 9 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::getFieldLabels()
  2. 8.9.x core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::getFieldLabels()
  3. 11.x core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::getFieldLabels()

Overrides DisplayPluginInterface::getFieldLabels

File

core/modules/views/src/Plugin/views/display/DisplayPluginBase.php, line 973

Class

DisplayPluginBase
Base class for views display plugins.

Namespace

Drupal\views\Plugin\views\display

Code

public function getFieldLabels($groupable_only = FALSE) {
    $options = [];
    foreach ($this->getHandlers('relationship') as $relationship => $handler) {
        $relationships[$relationship] = $handler->adminLabel();
    }
    foreach ($this->getHandlers('field') as $id => $handler) {
        if ($groupable_only && !$handler->useStringGroupBy()) {
            // Continue to next handler if it's not groupable.
            continue;
        }
        if ($label = $handler->label()) {
            $options[$id] = $label;
        }
        else {
            $options[$id] = $handler->adminLabel();
        }
        if (!empty($handler->options['relationship']) && !empty($relationships[$handler->options['relationship']])) {
            $options[$id] = '(' . $relationships[$handler->options['relationship']] . ') ' . $options[$id];
        }
    }
    return $options;
}

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