You are here

public function DisplayPluginBase::getFieldLabels in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::getFieldLabels()

Retrieves a list of fields for the current display.

This also takes into account any associated relationships, if they exist.

Parameters

bool $groupable_only: (optional) TRUE to only return an array of field labels from handlers that support the useStringGroupBy method, defaults to FALSE.

Return value

array An array of applicable field options, keyed by ID.

Overrides DisplayPluginInterface::getFieldLabels

File

core/modules/views/src/Plugin/views/display/DisplayPluginBase.php, line 967
Contains \Drupal\views\Plugin\views\display\DisplayPluginBase.

Class

DisplayPluginBase
Base class for views display plugins.

Namespace

Drupal\views\Plugin\views\display

Code

public function getFieldLabels($groupable_only = FALSE) {
  $options = array();
  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;
}