You are here

public function RulesEvaluationException::__construct in Rules 7.2

Constructor.

Parameters

string $msg: The exception message containing placeholder as t().

array $args: Replacement arguments such as for t().

$element: The element of a configuration causing the exception or an array consisting of the element and keys specifying a setting value causing the exception.

int $severity: The RulesLog severity. Defaults to RulesLog::WARN.

File

includes/rules.core.inc, line 2847
Rules base classes and interfaces needed for any rule evaluation.

Class

RulesEvaluationException
An exception that is thrown during evaluation.

Code

public function __construct($msg, array $args = array(), $element = NULL, $severity = RulesLog::WARN) {
  $this->element = is_array($element) ? array_shift($element) : $element;
  $this->keys = is_array($element) ? $element : array();
  $this->msg = $msg;
  $this->args = $args;
  $this->severity = $severity;

  // If an error happened, run the integrity check on the rules configuration
  // and mark it as dirty if it the check fails.
  if ($severity == RulesLog::ERROR && isset($this->element)) {
    $rules_config = $this->element
      ->root();
    rules_config_update_dirty_flag($rules_config);

    // If we discovered a broken configuration, exclude it in future.
    if ($rules_config->dirty) {
      rules_clear_cache();
    }
  }

  // @todo Fix _drupal_decode_exception() to use __toString() and override it.
  $this->message = t($this->msg, $this->args);
}