You are here

function views_rules_collect_rows_info_alter in Views Rules 7

Alters info for the action.

File

rules/views_rules.action.inc, line 35
Action implementation.

Code

function views_rules_collect_rows_info_alter(&$info, RulesAbstractPlugin $element) {

  // Add view display variables.
  if (!empty($element->settings['views_rules_display']) && ($view = views_rules_get_view($element->settings['views_rules_display']))) {

    // Abort if view does not validate.
    if (!$view
      ->validate()) {
      return;
    }

    /** @var $iterator views_rules_iterator */
    $iterator = $view->display_handler;
    if (!$iterator instanceof views_rules_iterator) {
      return;
    }

    // Add view arguments.
    foreach ($iterator
      ->get_rules_parameter_info() as $var_name => $var_info) {
      $info['parameter'][$var_name] = $var_info;
    }

    // Add view row variable lists.
    foreach ($iterator
      ->get_rules_variable_info() as $var_name => $var_info) {
      $type = $var_info['type'];
      $label = $var_info['label'];
      $info['provides'][$var_name] = array(
        // Change variable to list.
        'type' => "list<{$type}>",
        'label' => t('List of @label', array(
          '@label' => $label,
        )),
      ) + $var_info;
    }
  }
}