public function 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.

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php, line 931
Contains Drupal\views\Plugin\views\display\DisplayPluginBase.

Class

DisplayPluginBase
The default display plugin handler. Display plugins handle options and basic mechanisms for different output methods.

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;
}