You are here

public function ViewsRulesLoop::integrityCheck in Views Rules 7

Return value

RulesContainerPlugin

Overrides RulesContainerPlugin::integrityCheck

File

rules/views_rules.plugin.inc, line 30
Views Rules plugin implementations.

Class

ViewsRulesLoop
Loop plugin for using results from a view with Rules displays.

Code

public function integrityCheck() {

  // Check view is configured.
  $view = $this
    ->getView();
  if (!$view) {
    throw new RulesIntegrityException(t('%plugin: View display is not configured.', array(
      '%plugin' => $this
        ->getPluginName(),
    )), $this);
  }

  // Check view display is an iterator.
  $display = $view->display_handler;
  if (!isset($display)) {
    throw new RulesIntegrityException(t('%plugin: Configured view display is missing.', array(
      '%plugin' => $this
        ->getPluginName(),
    )), $this);
  }
  if (!$display instanceof views_rules_iterator) {
    throw new RulesIntegrityException(t('%plugin: Configured view display is not a Rules iterator.', array(
      '%plugin' => $this
        ->getPluginName(),
    )), $this);
  }

  // Validate view display.
  if (!$view
    ->validate()) {
    throw new RulesIntegrityException(t('%plugin: Configured view does not validate.', array(
      '%plugin' => $this
        ->getPluginName(),
    )), $this);
  }
  parent::integrityCheck();

  // Check row variables.

  /** @var $display views_rules_iterator */
  foreach ($display
    ->get_rules_variable_info() as $name => $info) {
    if (isset($this->settings[$name . ':var'])) {
      $this
        ->checkVarName($this->settings[$name . ':var']);
    }
  }
}