You are here

public function WebformViewsSelectHandler::execute in Webform Views Select 7

Returns the list of select options in the format required by Webform.

Overrides views_plugin_display::execute

1 call to WebformViewsSelectHandler::execute()
WebformViewsSelectHandler::render in ./WebformViewsSelectHandler.inc
Render this display.

File

./WebformViewsSelectHandler.inc, line 42
Contains WebformViewsSelectHandler.

Class

WebformViewsSelectHandler
The plugin that handles webform_views_select_handler.

Code

public function execute($flat = FALSE) {

  // Render the fields.
  $results = array();
  if (!empty($this->view->result) || $this->view->style_plugin
    ->even_empty()) {
    $results = $this->view->style_plugin
      ->render_fields($this->view->result);
  }
  else {

    // There are no results. Stop processing here.
    return array();
  }

  // Do not group if a flat list is requested.
  if ($flat) {
    $grouping_options = array();
  }
  else {

    // Check if there are grouping options set.
    if (isset($this->view->style_options['grouping'])) {
      $grouping_options = $this->view->style_options['grouping'];
    }
    else {
      $grouping_options = array();
    }
  }

  // Group the rows according to the grouping instructions, if specified.
  $sets = $this->view->style_plugin
    ->render_grouping($results, $grouping_options, TRUE);
  $rows = $this->view->style_plugin
    ->render_grouping_sets($sets);
  if (empty($grouping_options) && !empty($rows)) {
    $rows = $rows[''];
  }
  return $rows;
}