You are here

function webform_references_execute_view in Webform References 7

3 calls to webform_references_execute_view()
webform_references_autocomplete_view in ./webform_references.module
webform_references_validate_node_reference in ./webform_references.node.inc
Validation Callback for node reference field.
_webform_references_list_from_view in ./webform_references.module
Helper function to get node list from a view.

File

./webform_references.module, line 139
Webform module node reference component.

Code

function webform_references_execute_view($view_name, $display_name, $entity_type, $args = array(), $match = NULL, $match_operator = 'CONTAINS', $limit = 0, $ids = NULL) {
  $result = array();

  // Check that the view is valid and the display still exists.
  $view = views_get_view($view_name);
  if (!$view || !isset($view->display[$display_name]) || !$view
    ->access($display_name)) {
    watchdog('entityreference', 'The view %view_name is no longer eligible.', array(
      '%view_name' => $view_name,
    ), WATCHDOG_WARNING);
    return array();
  }
  $view
    ->set_display($display_name);

  // Make sure the query is not cached.
  $view->is_cacheable = FALSE;

  // Set the options for the display handler.
  $entityreference_options = array(
    'match' => $match,
    'match_operator' => $match_operator,
    'limit' => $limit,
    'ids' => $ids,
  );
  $view->display_handler
    ->set_option('entityreference_options', $entityreference_options);
  $result = $view
    ->execute_display($display_name, $args);
  return $result;
}