You are here

class ViewsRulesResultCollector in Views Rules 7

Collector for view iterator results.

Hierarchy

Expanded class hierarchy of ViewsRulesResultCollector

File

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

View source
class ViewsRulesResultCollector implements ViewsRulesIterable {

  /**
   * Variables to collect data for.
   * @var array
   */
  protected $variables;

  /**
   * Collected data.
   * @var array
   */
  protected $data = array();

  /**
   * Creates a collector.
   *
   * @param array $variables
   *   Names of variables to collect.
   */
  public function __construct(array $variables) {
    $this->variables = $variables;
    foreach ($this->variables as $variable) {
      $this->data[$variable] = array();
    }
  }

  /**
   * Evaluates a view row in the loop.
   */
  public function evaluateRow(array $data) {

    // Collect data for each variable.
    foreach ($this->variables as $variable) {
      $this->data[$variable][] = isset($data[$variable]) ? $data[$variable] : NULL;
    }
  }

  /**
   * Returns collected data.
   */
  public function getData() {
    return $this->data;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ViewsRulesResultCollector::$data protected property Collected data.
ViewsRulesResultCollector::$variables protected property Variables to collect data for.
ViewsRulesResultCollector::evaluateRow public function Evaluates a view row in the loop. Overrides ViewsRulesIterable::evaluateRow
ViewsRulesResultCollector::getData public function Returns collected data.
ViewsRulesResultCollector::__construct public function Creates a collector.